/* Custom CSS for IMAP Email Browser */

/* Layout fixes */
html, body {
    height: 100%;
    font-size: 14px;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

/* Responsive font scaling */
@media (max-width: 575px) {
    html { font-size: 16.8px; } /* 21px * 0.8 = 16.8px (20% reduction from previous 1.5x scaling) */
}

@media (min-width: 576px) {
    html { font-size: 15px; }
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

@media (min-width: 992px) {
    html { font-size: 16px; }
}

/* Touch-friendly button sizes */
.btn {
    min-height: 38px;
    padding: 0.5rem 1rem;
}

.btn-sm {
    min-height: 36px;
    padding: 0.4rem 0.8rem;
}

/* Mobile sidebar toggle */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    top: 70px;
    left: 15px;
    z-index: 1040;
    background: var(--bs-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.mobile-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    z-index: 1050;
    transition: left 0.3s ease;
    background: var(--bs-dark);
    border-right: 1px solid var(--bs-border-color);
    padding-top: 56px;
}

.mobile-sidebar.show {
    left: 0;
}

.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1045;
}

.mobile-sidebar-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--bs-text-color);
    cursor: pointer;
    z-index: 1051;
}

/* Folder sidebar styling */
.folder-item {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
    background-color: var(--bs-dark);
    color: var(--bs-light);
}

.folder-item:hover {
    background-color: var(--bs-primary);
    color: white;
    border-left: 4px solid var(--bs-info);
}

.folder-item.active {
    background-color: var(--bs-primary);
    color: white;
    border-left: 4px solid var(--bs-info);
    font-weight: 500;
}

.folder-item.active:hover {
    background-color: var(--bs-primary);
}

/* Message list styling */
.message-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.message-row:hover {
    background-color: var(--bs-light);
}

.message-row.fw-bold {
    font-weight: 600 !important;
}

/* Connection status indicator */
#connection-status {
    font-size: 0.875rem;
}

/* Loading states */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Form enhancements */
.form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

/* Alert improvements */
.alert {
    border-left: 4px solid;
    border-left-color: currentColor;
}

.alert-success {
    border-left-color: var(--bs-success);
}

.alert-danger {
    border-left-color: var(--bs-danger);
}

.alert-warning {
    border-left-color: var(--bs-warning);
}

.alert-info {
    border-left-color: var(--bs-info);
}

/* Card enhancements */
.card {
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.card.border-primary {
    border-color: var(--bs-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Button improvements */
.btn {
    transition: all 0.2s ease;
    border-radius: 6px;
    font-weight: 500;
    padding: 0.5rem 1rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
}

/* Proportional button sizes */
@media (max-width: 576px) {
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Icon spacing in buttons */
.btn i {
    margin-right: 0.25rem;
}

.btn i:only-child {
    margin: 0;
}

/* Table improvements */
.table-hover tbody tr:hover {
    background-color: var(--bs-light);
}

/* Preview modal improvements */
.modal {
    z-index: 1055 !important;
}

.modal-backdrop {
    z-index: 1050 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
}

.modal-content {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    background-color: var(--bs-dark) !important;
    position: relative;
    z-index: 1060 !important;
}

.modal-header {
    border-bottom: 1px solid var(--bs-border-color);
    background-color: var(--bs-dark);
    z-index: 1061 !important;
}

.modal-body {
    background-color: var(--bs-dark) !important;
    z-index: 1060 !important;
}

/* Ensure modal content is clickable and properly layered */
.modal-dialog {
    z-index: 1060 !important;
    pointer-events: all !important;
}

/* Fix for article links being clickable */
.article-item a {
    position: relative;
    z-index: 1065 !important;
    pointer-events: all !important;
}

.article-title a {
    pointer-events: all !important;
    cursor: pointer !important;
}

/* Text truncation helpers */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Article checkbox styling */
.article-item .form-check {
    margin-top: 0.1rem;
}

.article-item .form-check-input {
    border-color: var(--bs-border-color);
    border-width: 1px;
    transform: scale(1.1);
}

.article-item .form-check-input:checked {
    background-color: var(--bs-success);
    border-color: var(--bs-success);
}

.article-item .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
    border-color: var(--bs-success);
}

/* Responsive improvements */
@media (max-width: 768px) {
    /* Hide original sidebar on mobile */
    .col-lg-3.col-md-4 {
        display: none;
    }

    /* Full width content area on mobile */
    .col-lg-9.col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
        min-height: calc(100vh - 56px);
    }

    /* Show mobile sidebar toggle */
    .mobile-sidebar-toggle {
        display: block;
    }

    /* Show mobile sidebar overlay when active */
    .mobile-sidebar-overlay.show {
        display: block;
    }

    .folder-item {
        padding: 1rem !important;
        min-height: 48px;
        display: flex;
        align-items: center;
        background-color: var(--bs-dark);
        color: var(--bs-light);
    }

    .table-responsive {
        font-size: 1.3rem; /* Increased from 0.875rem */
    }

    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }

    /* Better touch targets */
    .message-row {
        min-height: 60px;
        padding: 0.75rem;
        font-size: 1.2rem; /* Increased font size */
    }

    /* Improve button spacing */
    .btn {
        min-height: 44px;
        margin-bottom: 0.25rem;
        font-size: 1.2rem; /* Increased font size */
    }

    /* Make search input larger */
    .form-control {
        min-height: 44px;
        font-size: 24px; /* Increased from 16px and prevents zoom on iOS */
    }

    /* Better spacing for mobile */
    .p-3 {
        padding: 1rem !important;
    }

    /* Improve navigation on mobile */
    .navbar {
        padding: 0.5rem 1rem;
    }

    .navbar-brand {
        font-size: 1.65rem; /* Increased from 1.1rem */
    }

    /* Mobile table improvements */
    .message-item {
        padding: 0.75rem;
        border-bottom: 1px solid var(--bs-border-color);
    }

    .message-header {
        margin-bottom: 0.5rem;
    }

    .message-from {
        font-size: 1.35rem; /* Increased from 0.9rem */
        max-width: 65%;
    }

    .message-date {
        font-size: 1.125rem; /* Increased from 0.75rem */
    }

    .message-subject {
        font-size: 1.275rem; /* Increased from 0.85rem */
        margin-bottom: 0.25rem;
    }

    /* Modal text size improvements */
    .modal-body {
        font-size: 1.2rem;
    }

    .modal-title {
        font-size: 1.65rem;
    }

    .modal-footer .btn {
        font-size: 1.2rem;
        padding: 0.75rem 1.5rem;
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .p-4 {
        padding: 1rem !important;
    }

    .p-3 {
        padding: 0.75rem !important;
    }

    /* Very small screen optimizations */
    .modal-dialog {
        margin: 0.25rem;
        max-width: calc(100vw - 0.5rem);
    }

    .mobile-sidebar {
        width: 100vw;
    }

    .mobile-sidebar-toggle {
        left: 10px;
        top: 65px;
    }

    /* Larger touch targets for very small screens */
    .btn {
        min-height: 48px;
        padding: 0.75rem 1rem;
    }

    .form-control {
        min-height: 48px;
        padding: 0.75rem;
    }

    /* Stack buttons vertically on very small screens */
    .btn-group-vertical .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .input-group-sm .form-control {
        font-size: 16px;
        min-height: 44px;
    }

    .input-group-sm .btn {
        min-height: 44px;
    }

    /* Improve message display on very small screens */
    .message-from {
        max-width: 60%;
        font-size: 0.85rem;
    }

    .message-subject {
        font-size: 0.8rem;
    }

    .message-date {
        font-size: 0.7rem;
    }

    /* Better modal content on small screens */
    .modal-body {
        padding: 1rem;
        max-height: 70vh;
        overflow-y: auto;
    }

    .modal-header .modal-title {
        font-size: 1rem;
    }
}

/* Adaptive spacing */
@media (min-width: 992px) {
    .p-4 {
        padding: 2rem !important;
    }

    .col-lg-3 {
        max-width: 280px;
    }
}

@media (min-width: 1200px) {
    .col-lg-3 {
        max-width: 320px;
    }
}

/* Dark theme improvements */
[data-bs-theme="dark"] .folder-item:hover {
    background-color: var(--bs-dark);
}

[data-bs-theme="dark"] .message-row:hover {
    background-color: var(--bs-dark);
}

[data-bs-theme="dark"] .bg-light {
    background-color: var(--bs-dark) !important;
}

[data-bs-theme="dark"] .border-end {
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .modal-header {
    background-color: var(--bs-dark);
}

[data-bs-theme="dark"] .modal-content {
    background-color: var(--bs-dark) !important;
}

[data-bs-theme="dark"] .modal-body {
    background-color: var(--bs-dark) !important;
}

/* Utility classes */
.cursor-pointer {
    cursor: pointer;
}

.user-select-none {
    user-select: none;
}

.text-nowrap-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Loading animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Smooth scrolling */
.overflow-auto {
    scroll-behavior: smooth;
}

/* Custom scrollbar - Desktop */
@media (min-width: 769px) {
    .overflow-auto::-webkit-scrollbar {
        width: 6px;
    }

    .overflow-auto::-webkit-scrollbar-track {
        background: var(--bs-light);
    }

    .overflow-auto::-webkit-scrollbar-thumb {
        background: var(--bs-secondary);
        border-radius: 3px;
    }

    .overflow-auto::-webkit-scrollbar-thumb:hover {
        background: var(--bs-primary);
    }
}

/* Loading spinner improvements */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Badge improvements */
.badge {
    font-size: 0.75em;
    font-weight: 500;
}

/* Focus improvements for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Print styles */
@media print {
    .navbar,
    .modal,
    .btn,
    .alert {
        display: none !important;
    }

    .container-fluid {
        padding: 0 !important;
    }

    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-outline-primary {
        border-width: 2px;
    }

    .card {
        border-width: 2px;
    }

    .alert {
        border-width: 2px;
    }

    .folder-item:hover,
    .folder-item.active {
        border-left-width: 6px;
    }
}

/* Enhanced visual hierarchy */
.fs-6 {
    font-size: 0.875rem !important;
    font-weight: 600;
}

.fw-medium {
    font-weight: 500;
}

/* Status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-indicator.connected {
    background-color: rgba(25, 135, 84, 0.1);
    color: var(--bs-success);
}

.status-indicator.disconnected {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--bs-danger);
}

/* Message row enhancements */
.message-row {
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.message-row:hover {
    border-left-color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.05);
}

.message-row.fw-bold {
    border-left-color: var(--bs-info);
}

/* Compact table styling */
.compact-cell {
    padding: 0.5rem 0.25rem !important;
}

.table > :not(caption) > * > * {
    padding: 0.5rem 0.25rem;
}

.table th {
    padding: 0.75rem 0.25rem !important;
    font-weight: 600;
}

/* Reduce table spacing */
.table-responsive table {
    margin-bottom: 0;
    table-layout: fixed;
    width: 100%;
}

.table tbody tr td:first-child {
    width: 35%;
}

.table tbody tr td:nth-child(2) {
    width: 45%;
}

.table tbody tr td:last-child {
    width: 20%;
}

/* Improved spacing for small screens */
@media (max-width: 576px) {
    .message-row td {
        padding: 0.5rem 0.25rem;
        font-size: 0.875rem;
    }

    .message-row td:first-child {
        padding-left: 0.75rem;
    }

    .message-row td:last-child {
        padding-right: 0.75rem;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Custom styles for Email Client */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fa;
}

.navbar {
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.main-container {
    height: calc(100vh - 76px);
}

.message-item {
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
    border-bottom: 1px solid #eee;
}

.message-item:hover {
    background-color: #f8f9fa;
}

.message-item.selected {
    background-color: #e3f2fd;
    border-left: 3px solid #1976d2;
}

.message-item.unread {
    font-weight: bold;
    background-color: #fff3e0;
}

.message-item.unread.selected {
    background-color: #e8f5e8;
}

.unread-indicator {
    width: 8px;
    height: 8px;
    background-color: #2196f3;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.message-from {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.message-date {
    font-size: 0.75rem;
    color: #666;
    white-space: nowrap;
}

.message-subject {
    color: #555;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-preview {
    color: #777;
    font-size: 0.8rem;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#message-content {
    height: calc(100vh - 200px);
    overflow-y: auto;
}

.message-full-header {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.message-meta div {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.message-body {
    line-height: 1.6;
}

.message-html {
    /* Contain HTML content styling */
    max-width: 100%;
    overflow-x: auto;
}

.message-html img {
    max-width: 100%;
    height: auto;
}

.message-html table {
    max-width: 100%;
    table-layout: fixed;
}

.message-text pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.25rem;
    font-size: 0.9rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .main-container {
        height: calc(100vh - 56px);
    }
}

/* Parsed Email Content Styles */
.article-item {
    transition: all 0.2s ease;
    border: 1px solid #e9ecef !important;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%) !important;
}

.article-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--bs-primary) !important;
}

.article-title {
    color: #2c3e50 !important;
    font-size: 1rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.article-title .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.article-description {
    color: #6c757d !important;
    font-size: 0.875rem;
    line-height: 1.5;
    text-align: justify;
}

.parsed-email-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.parsed-email-header h6 {
    color: white !important;
}

.parsed-email-header .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

.articles-count-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.view-original-btn {
    transition: all 0.2s ease;
}

.view-original-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Dark theme support for parsed content */
[data-bs-theme="dark"] .article-item {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%) !important;
    border-color: #4a5568 !important;
}

[data-bs-theme="dark"] .article-title {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .article-description {
    color: #a0aec0 !important;
}

[data-bs-theme="dark"] .parsed-email-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

/* Animation for article items */
.article-item {
    animation: slideInUp 0.3s ease-out;
}

/* Article link styles */
.article-title a {
    color: #2c3e50 !important;
    transition: color 0.2s ease;
}

.article-title a:hover {
    color: var(--bs-primary) !important;
    text-decoration: underline !important;
}

[data-bs-theme="dark"] .article-title a {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .article-title a:hover {
    color: #74c0fc !important;
}

/* URL display styling */
.article-item .small.text-muted {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    word-break: break-all;
    opacity: 0.8;
}

.article-item .small.text-muted a {
    color: inherit !important;
    transition: color 0.2s ease;
}

.article-item .small.text-muted a:hover {
    color: var(--bs-primary) !important;
    text-decoration: underline !important;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive improvements for articles */
@media (max-width: 768px) {
    .article-item {
        margin-bottom: 1rem !important;
        padding: 1rem !important;
    }

    .article-title {
        font-size: 0.9rem;
    }

    .article-description {
        font-size: 0.8rem;
    }

    .articles-count-badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
}

/* Email parsing status indicators */
.parsing-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.parsing-status.success {
    background-color: rgba(25, 135, 84, 0.1);
    color: var(--bs-success);
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.parsing-status.fallback {
    background-color: rgba(255, 193, 7, 0.1);
    color: #856404;
    border: 1px solid rgba(255, 193, 7, 0.2);
}

/* Read time indicators */
.read-time-indicator {
    background: rgba(13, 110, 253, 0.15);
    color: #0d4e84;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Enhanced Mobile Modal Optimizations */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }

    .modal-dialog {
        margin: 0;
        height: 100vh;
        max-width: 100vw;
        border-radius: 0;
    }

    .modal-content {
        height: 100vh;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        padding: 1rem;
        border-bottom: 2px solid var(--bs-border-color);
        flex-shrink: 0;
        background: var(--bs-dark);
    }

    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        flex-grow: 1;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 80px; /* Reduced space for smaller footer */
    }

    .modal-footer {
        padding: 1rem;
        border-top: 2px solid var(--bs-border-color);
        flex-shrink: 0;
        background: var(--bs-dark);
        z-index: 1060;
        display: flex;
        justify-content: center;
    }

    /* Hide mark as read button in mobile modal footer */
    .modal-footer #mark-read-btn {
        display: none !important;
    }

    .modal-title {
        font-size: 1.1rem;
        font-weight: 600;
    }

    .btn-close {
        padding: 0.75rem;
        margin: -0.75rem;
        font-size: 1.2rem;
    }

    /* Style for mobile modal buttons in content area */
    .mobile-modal-buttons {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin: 1rem 0;
        align-items: center;
    }

    .mobile-modal-buttons .btn {
        min-width: 200px;
        padding: 0.75rem 1.5rem;
    }
}

/* Enhanced Scrolling Behaviors */
.overflow-auto {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Mobile-friendly message list */
@media (max-width: 768px) {
    #messages-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    .message-item {
        border-bottom: 1px solid var(--bs-border-color);
        transition: background-color 0.2s ease;
    }

    .message-item:active {
        background-color: rgba(var(--bs-primary-rgb), 0.1);
    }

    /* Better scrollbar for mobile webkit browsers */
    #messages-container::-webkit-scrollbar {
        width: 4px;
    }

    #messages-container::-webkit-scrollbar-track {
        background: transparent;
    }

    #messages-container::-webkit-scrollbar-thumb {
        background: rgba(var(--bs-secondary-rgb), 0.5);
        border-radius: 2px;
    }

    /* Pull-to-refresh indicator space */
    #messages-container {
        padding-top: 1px;
    }
}

/* Dark theme mobile modal adjustments */
[data-bs-theme="dark"] .mobile-sidebar {
    background: var(--bs-dark);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .mobile-sidebar-toggle {
    background: var(--bs-primary);
}

[data-bs-theme="dark"] .mobile-sidebar-close {
    color: var(--bs-light);
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }

    /* Fix for iOS bottom safe area */
    @media (max-width: 768px) {
        .modal-footer {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        }
    }
}

/* Better touch feedback */
@media (max-width: 768px) {
    .btn:active,
    .message-row:active,
    .folder-item:active {
        transform: scale(0.98);
        background-color: rgba(var(--bs-primary-rgb), 0.1);
    }

    /* Improved tap targets */
    .btn,
    .form-control,
    .folder-item,
    .message-row {
        min-height: 44px;
    }

    /* Better spacing for touch */
    .btn + .btn {
        margin-top: 0.5rem;
    }

    .form-control + .btn {
        margin-top: 0.5rem;
    }
}

/* Prevent zoom on input focus for iOS */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Loading states mobile optimization */
@media (max-width: 768px) {
    .loading-overlay {
        background: rgba(0, 0, 0, 0.7);
    }

    .spinner-border {
        width: 3rem;
        height: 3rem;
    }

    .spinner-border-sm {
        width: 1.5rem;
        height: 1.5rem;
    }
}