/* Custom styles for Medium-like blogging platform */

/* Typography */
body {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    line-height: 1.6;
    color: rgba(0, 0, 0, 0.8);
    background-color: #fff;
    font-size: 18px;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-weight: 700;
}

/* Blog post styles */
.blog-post {
    margin-bottom: 3rem;
    border-radius: 4px;
    border: none;
}

.blog-post-title {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-size: 32px;
    line-height: 1.25;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: -0.015em;
}

.blog-post-title a {
    color: rgba(0, 0, 0, 0.8);
    text-decoration: none;
}

.blog-post-title a:hover {
    color: #198754;
}

/* Featured image styling */
.featured-image-container {
    position: relative;
    width: 100%;
    height: 150px;
    overflow: hidden;
    border-radius: 0.25rem;
    background-color: transparent;
}

.featured-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

/* Feature image styling for homepage */
.feature-image-container {
    position: relative;
    width: 100%;
    overflow: visible;
    border-radius: 0;
    background-color: transparent;
}

.feature-image {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
    border-radius: 0;
    box-shadow: none;
}

.featured-image-container:hover .featured-image,
.feature-image-container:hover .feature-image {
    transform: scale(1.05);
}

.blog-post-meta {
    margin-bottom: 1.5rem;
    color: rgba(0, 0, 0, 0.54);
    font-size: 15px;
    font-family: 'Source Sans Pro', sans-serif;
}

.blog-post-content {
    font-family: 'Merriweather', Georgia, 'Times New Roman', serif;
    font-size: 18px;
    line-height: 1.8;
    color: rgba(0, 0, 0, 0.8);
}

/* Post content markdown styling */
.markdown-content {
    font-family: 'Merriweather', Georgia, 'Times New Roman', serif;
    color: rgba(0, 0, 0, 0.8);
}

.markdown-content h1, 
.markdown-content h2, 
.markdown-content h3, 
.markdown-content h4, 
.markdown-content h5, 
.markdown-content h6 {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.markdown-content h1 {
    font-size: 32px;
}

.markdown-content h2 {
    font-size: 28px;
}

.markdown-content p {
    margin-bottom: 1.75rem;
    font-size: 18px;
    line-height: 1.8;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    margin: 2rem 0;
    border-radius: 4px;
}

.markdown-content blockquote {
    border-left: 3px solid rgba(0, 0, 0, 0.84);
    padding-left: 20px;
    margin-left: -23px;
    font-style: italic;
    margin-bottom: 2rem;
    color: rgba(0, 0, 0, 0.68);
}

.markdown-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 2rem;
    overflow-x: auto;
}

.markdown-content code {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 16px;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Author card */
.author-card {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 2rem;
    margin-top: 3rem;
}

.author-bio {
    font-size: 16px;
    color: rgba(0, 0, 0, 0.54);
    font-family: 'Source Sans Pro', sans-serif;
}

/* Dashboard styles */
.dashboard-header {
    margin-bottom: 2.5rem;
}

.story-item {
    position: relative;
    transition: all 0.2s ease;
}

.story-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.post-card {
    transition: box-shadow 0.2s ease-in-out;
    border: none;
    border-radius: 4px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.post-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* User profile */
.profile-header {
    margin-bottom: 3rem;
    text-align: center;
}

.profile-bio {
    font-style: italic;
    margin-bottom: 2rem;
    color: rgba(0, 0, 0, 0.6);
    font-size: 18px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Form styling */
.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-control:focus {
    box-shadow: none;
    border-color: #198754;
}

.form-control-lg {
    font-size: 1.25rem;
}

/* Medium-like free flowing editor - unrestricted version */
body {
    overflow-y: auto !important;
    position: relative;
    height: auto !important;
    min-height: 100vh !important;
}

/* Force containers to expand naturally */
html, body, main, .container-fluid, .container, .row, .col, 
form, .editor-main-column, .editor-grid-layout, .blog-post-container {
    min-height: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
}

/* Editor text area with unrestricted height */
#content {
    width: 100% !important;
    min-height: 500px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    resize: none !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    font-family: 'Merriweather', Georgia, serif !important;
    font-size: 18px !important;
    line-height: 1.8 !important;
    background-color: transparent !important;
    position: static !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
}

#content:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Grid layout for editor */
.editor-grid-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) !important;
    grid-gap: 30px !important;
    align-items: start !important; 
    width: 100% !important;
    min-height: 100vh !important; 
    overflow: visible !important;
}

/* Override all Bootstrap form-control styles */
.free-flow-editor.form-control {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

/* Preview container */
#preview-container {
    width: 100%;
    max-width: 740px;
    margin: 0 auto;
    font-family: 'Merriweather', Georgia, serif;
    font-size: 18px;
    line-height: 1.8;
}

/* AI tools container */
#ai-writing-tools {
    width: 100%;
    max-width: 740px;
    margin: 20px auto;
    padding: 0;
}

/* AI assistant container styling */
.ai-assistant-container {
    max-width: 740px;
    margin: 30px auto;
}

/* Response area for AI suggestions */
.ai-response-area {
    background-color: rgba(25, 135, 84, 0.05);
    border-radius: 0.25rem;
    padding: 1rem;
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

/* Hide when empty */
.ai-response-area:empty {
    display: none;
}

/* Buttons */
.btn-primary {
    background-color: #198754;
    border-color: #198754;
}

.btn-primary:hover {
    background-color: #146c43;
    border-color: #146c43;
}

.btn-outline-primary {
    color: #198754;
    border-color: #198754;
}

.btn-outline-primary:hover {
    background-color: #198754;
    border-color: #198754;
}

/* Links */
a {
    color: #198754;
}

a:hover {
    color: #146c43;
}

/* Custom container width for blog posts */
@media (min-width: 992px) {
    .blog-post-container {
        max-width: 740px;
    }
}

/* Homepage article cards */
.article-card {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    transition: transform 0.2s ease;
}

.article-card:hover {
    transform: translateY(-3px);
}

.article-card:last-child {
    border-bottom: none;
}

.article-card img {
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.article-card img:hover {
    transform: scale(1.02);
}

/* Pagination styling - Medium-like */
.page-link {
    color: #198754;
    padding: 0.375rem 0.75rem;
    border: none;
}

.page-item.active .page-link {
    background-color: #198754;
    border-color: #198754;
}

/* Search page */
.search-result {
    margin-bottom: 2rem;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 1rem;
}

.search-result:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Medium-like rounded pills and buttons */
.rounded-pill {
    border-radius: 100px !important;
}

.btn-success {
    background-color: #198754;
    border-color: #198754;
}

.btn-success:hover, .btn-success:focus {
    background-color: #146c43;
    border-color: #146c43;
}

.text-success {
    color: #198754 !important;
}

/* Custom navbar styling */
.navbar {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Enhanced responsive styling for mobile devices */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }
    .blog-post-title {
        font-size: 24px;
    }
    .markdown-content h1 {
        font-size: 24px;
    }
    .markdown-content h2 {
        font-size: 20px;
    }
    .markdown-content p {
        font-size: 16px;
    }
    /* Improve mobile navigation */
    .navbar {
        padding: 0.5rem 1rem;
    }
    /* Better spacing for mobile content */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    /* Make search more usable on mobile */
    .d-flex.me-2 {
        width: 100%;
        margin-bottom: 10px;
    }
    /* Fix padding for main content */
    main.container {
        padding-top: 1rem;
        padding-bottom: 2rem;
    }
    /* Adjust hero section for mobile */
    .hero-title {
        font-size: 2rem;
    }
    .hero-subtitle {
        font-size: 1.2rem;
    }
    /* Make buttons larger and easier to tap */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
    /* Ensure proper spacing in footer */
    footer {
        text-align: center;
    }
    footer .text-md-end {
        text-align: center !important;
        margin-top: 15px;
    }
    /* Better card spacing */
    .card {
        margin-bottom: 1.5rem;
    }
    /* Adjust form controls for mobile */
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Medium-like dropdown menu */
.dropdown-menu {
    border: none;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.dropdown-item:active {
    background-color: #f8f9fa;
    color: #212529;
}

/* Social sharing buttons */
.dropdown-item i.fab.fa-twitter,
.dropdown-item i.fas.fa-envelope {
    color: #1DA1F2;
}

.dropdown-item i.fab.fa-facebook {
    color: #4267B2;
}

.dropdown-item i.fab.fa-linkedin {
    color: #0e76a8;
}

.dropdown-item i.fab.fa-reddit {
    color: #FF4500;
}

.dropdown-item:hover {
    background-color: rgba(25, 135, 84, 0.1);
}

/* Medium-like hero section */
.hero-section {
    padding: 5rem 0;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1.1;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: rgba(0, 0, 0, 0.6);
    margin-bottom: 2rem;
}

/* Footer styling - ensure it doesn't block content expansion */
footer {
    background-color: #fff;
    color: rgba(0, 0, 0, 0.6);
    padding: 3rem 0;
    position: relative !important;
    z-index: 10;
    /* Remove any fixed positioning that might be interfering */
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
}

/* Inline AI Assistant */
#inline-ai-assistant {
    transition: all 0.2s ease-in-out;
}

#inline-ai-button {
    opacity: 0.9;
    transition: all 0.2s ease;
    cursor: move; /* Cursor indicates element is draggable */
}

#inline-ai-button:hover {
    opacity: 1;
    transform: scale(1.05);
}

#inline-ai-dropdown {
    animation: fadeIn 0.2s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(-10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Draggable element styling */
.draggable {
    position: fixed;
    cursor: move;
    user-select: none;
    z-index: 1000;
}

.draggable.dragging {
    opacity: 0.8;
    transition: none; /* Remove transitions during dragging for better performance */
}

.drag-handle {
    cursor: move;
}

/* Styling for undo button */
#inline-ai-undo:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#inline-ai-undo:not(:disabled):hover {
    background-color: #e2e6ea;
    border-color: #dae0e5;
}

/* Medium.com exact styling */
.medium-editor-container {
    position: relative;
    width: 100%;
    margin-bottom: 30px;
}

.medium-editor-content {
    -webkit-text-size-adjust: 100%;
    --x-height-multiplier: 0;
    --baseline-multiplier: 0;
    font-family: medium-content-sans-serif-font,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;
    letter-spacing: 0;
    font-weight: 400;
    font-style: normal;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    color: rgba(0,0,0,.84);
    font-size: 20px;
    line-height: 1.4;
    visibility: visible;
    -webkit-user-modify: read-write;
    -webkit-line-break: after-white-space;
    position: relative;
    outline: 0;
    word-break: break-word;
    word-wrap: break-word;
    margin-bottom: 50px;
    margin-top: 3px;
    width: 100% !important;
    min-height: 500px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    resize: none !important;
    border: none !important;
    background-color: transparent !important;
}

/* Additional Mobile-Specific Enhancements */
@media (max-width: 768px) {
    /* Header and navbar adjustments */
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .navbar-toggler {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Adjust search form for mobile */
    .search-form {
        width: 100% !important;
        margin: 0.5rem 0 !important;
    }
    
    /* Improve content readability on mobile */
    .container {
        padding-left: 15px;
        padding-right: 15px;
        width: 100%;
        max-width: 100%;
    }
    
    /* Fix editor and content display on small screens */
    .editor-grid-layout {
        display: block !important;
        grid-template-columns: 1fr !important;
    }
    
    /* Improve form elements on mobile */
    input, select, textarea, .form-control {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
    
    /* Make buttons more tappable */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Adjust modal dialogs */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    /* Make images responsive */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Fix Medium editor content on mobile */
    .medium-editor-content {
        font-size: 18px !important;
        padding: 0 10px !important;
    }
    
    /* Adjust AI tools for mobile */
    #ai-writing-tools {
        padding: 10px;
    }
    
    #ai-writing-tools button {
        margin-bottom: 8px;
    }
}
