/* ============================================
   AGOCARE RESPONSIVE DESIGN
   Mobile-first responsive overrides
   ============================================ */

/* ---- Hamburger Menu Button ---- */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1100;
    border-radius: 8px;
    transition: background 0.2s;
}

.hamburger-btn:hover {
    background: #f3f4f6;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #374151;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ---- Mobile Sidebar Overlay ---- */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-sidebar-overlay.active {
    opacity: 1;
}

/* ---- Mobile Sidebar ---- */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 1600;
    overflow-y: auto;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    padding: 0 0 20px 0;
}

.mobile-sidebar.active {
    left: 0;
}

.mobile-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #4b5563;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.mobile-sidebar .nav-item:hover,
.mobile-sidebar .nav-item.active {
    background: #f0fdfa;
    color: #0d9488;
}

.mobile-sidebar .nav-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    padding: 16px 20px 8px 20px;
    letter-spacing: 0.05em;
}

.mobile-sidebar .nav-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 16px;
}

/* ---- Global Image Responsiveness ---- */
img {
    max-width: 100%;
    height: auto;
}

/* ---- Global Box Sizing ---- */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ============================================
   TABLET BREAKPOINT - Below 1024px
   ============================================ */
@media screen and (max-width: 1024px) {
    /* Hide right sidebar on tablet */
    .main-layout > aside:last-child {
        display: none !important;
    }

    /* 2-column layout on tablet */
    .main-layout {
        grid-template-columns: 240px 1fr !important;
    }

    /* Doctor dashboard stat cards - 3 columns on tablet */
    .stat-cards-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Doctor dashboard bottom grid */
    .bottom-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   MOBILE BREAKPOINT - Below 768px
   ============================================ */
@media screen and (max-width: 768px) {
    /* Show hamburger */
    .hamburger-btn {
        display: flex !important;
    }

    /* Header adjustments */
    .site-header {
        padding: 8px 12px !important;
        height: 56px !important;
    }

    /* Hide desktop search in header */
    .header-search {
        display: none !important;
    }

    /* Compact header right section */
    .header-right {
        gap: 8px !important;
    }

    .header-right .ask-question-btn-text {
        display: none !important;
    }

    /* Hide desktop left sidebar */
    .desktop-sidebar {
        display: none !important;
    }

    /* Single column layout */
    .main-layout {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
        padding: 64px 12px 12px 12px !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Main content adjustments */
    .main-layout > main {
        height: auto !important;
        overflow: visible !important;
    }

    /* Hide right sidebar on mobile */
    .main-layout > aside {
        display: none !important;
    }

    /* Show mobile right sidebar below main on mobile (optional - keep hidden) */
    .main-layout > aside:last-child {
        display: none !important;
    }

    /* Body overflow fix */
    body {
        overflow: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
    }

    html {
        overflow: auto !important;
        height: auto !important;
    }

    /* Content wrapper */
    .content-wrapper {
        padding: 64px 12px 20px 12px !important;
        height: auto !important;
        overflow: visible !important;
        max-width: 100% !important;
    }

    /* Doctor dashboard stat cards - 2 columns */
    .stat-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .stat-card {
        padding: 12px !important;
    }

    .stat-value {
        font-size: 20px !important;
    }

    .stat-icon {
        width: 40px !important;
        height: 40px !important;
    }

    /* Sort buttons - scrollable */
    .sort-controls {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 4px;
    }

    /* Modal full width on mobile */
    .modal-content {
        width: 95% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        margin: 20px auto !important;
        padding: 16px !important;
    }

    .modal-overlay {
        padding: 10px !important;
        align-items: flex-start !important;
        padding-top: 40px !important;
    }

    /* User menu & notifications dropdown - full width on mobile */
    #user-menu {
        right: 10px !important;
        left: 10px !important;
        min-width: unset !important;
        width: auto !important;
    }

    #notifications-menu {
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
    }

    /* Make form inputs touch-friendly */
    input, select, textarea, button {
        font-size: 16px !important;
        min-height: 44px;
    }

    /* Touch-friendly buttons */
    button, .submit-btn, .social-btn, .action-btn, .btn-primary, .btn-secondary {
        min-height: 44px;
        padding: 12px 16px !important;
    }

    /* Doctor dashboard bottom grid */
    .bottom-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Questions filter buttons on doctor dashboard */
    .filter-controls {
        flex-wrap: wrap;
        gap: 6px !important;
    }

    /* Post creation area */
    .post-creation-area {
        padding: 12px !important;
        border-radius: 12px !important;
    }

    .post-action-buttons {
        flex-wrap: wrap;
    }

    /* Login page specific */
    .auth-card {
        padding: 24px 20px !important;
        margin: 10px;
        border-radius: 12px !important;
    }

    .auth-header {
        margin-bottom: 20px !important;
    }

    .logo-text {
        font-size: 24px !important;
    }

    /* Signup role selector */
    .role-selector {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    .role-option {
        padding: 12px 8px !important;
    }

    /* Tables to cards */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Toast container */
    .toast-container {
        left: 10px !important;
        right: 10px !important;
        top: 10px !important;
    }

    /* Appointment cards responsive */
    .appointment-card,
    .request-card {
        flex-direction: column !important;
    }

    .appointment-card .card-actions,
    .request-card .card-actions {
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px !important;
        margin-top: 12px;
    }

    /* Mobile search bar - shown below header */
    .mobile-search {
        display: block !important;
        padding: 8px 12px;
        background: white;
        border-bottom: 1px solid #e5e7eb;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        z-index: 999;
    }

    .mobile-search input {
        width: 100%;
        padding: 10px 16px 10px 40px;
        border: 1px solid #e5e7eb;
        border-radius: 20px;
        font-size: 14px !important;
        min-height: 40px;
    }

    /* Adjust content top when mobile search is present */
    .has-mobile-search .content-wrapper,
    .has-mobile-search .main-layout {
        padding-top: 115px !important;
    }
}

/* ============================================
   SMALL MOBILE BREAKPOINT - Below 480px
   ============================================ */
@media screen and (max-width: 480px) {
    /* Header even more compact */
    .site-header {
        padding: 6px 8px !important;
        height: 52px !important;
    }

    .site-header img[alt="Agocare"] {
        height: 32px !important;
    }

    /* Content wrapper narrower padding */
    .content-wrapper {
        padding: 60px 8px 16px 8px !important;
    }

    .main-layout {
        padding: 60px 8px 16px 8px !important;
        gap: 0 !important;
    }

    /* Stat cards single column */
    .stat-cards-grid {
        grid-template-columns: 1fr !important;
    }

    /* Login/Signup card */
    .auth-card {
        padding: 20px 16px !important;
        margin: 8px;
    }

    .auth-container {
        padding: 8px !important;
    }

    /* Role selector single column on very small screens */
    .role-selector {
        grid-template-columns: 1fr !important;
    }

    /* Modal takes full width */
    .modal-content {
        width: 100% !important;
        border-radius: 12px 12px 0 0 !important;
        margin: 0 !important;
        max-height: 95vh !important;
    }

    .modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    /* Smaller text */
    h1 {
        font-size: 20px !important;
    }

    h2 {
        font-size: 16px !important;
    }

    h3 {
        font-size: 14px !important;
    }

    /* Post creation input */
    .post-creation-area {
        padding: 10px !important;
    }

    .post-creation-area input[type="text"] {
        padding: 10px 14px !important;
        font-size: 14px !important;
    }

    /* User avatar smaller */
    #patientAvatar, #doctorAvatar {
        width: 34px !important;
        height: 34px !important;
        font-size: 12px !important;
    }

    /* Ask question button - icon only */
    .ask-question-btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }

    /* Compact sort buttons */
    .sort-btn {
        padding: 5px 12px !important;
        font-size: 12px !important;
    }

    /* Guest section buttons compact */
    #guest-section a {
        padding: 6px 12px !important;
        font-size: 13px !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block !important;
}

@media screen and (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }
    
    .desktop-only {
        display: none !important;
    }

    .mobile-flex {
        display: flex !important;
    }
}

/* Prevent horizontal overflow */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Make all images responsive by default */
img {
    max-width: 100%;
    height: auto;
}

/* ---- Mobile Sidebar Top Row ---- */
.mobile-sidebar-top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.mobile-sidebar-search {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    min-height: 40px;
}

.mobile-sidebar-search:focus {
    border-color: #0d9488;
}

/* ============================================
   MOBILE SIDEBAR CLOSE BUTTON
   ============================================ */
.mobile-sidebar-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1700;
    color: #374151;
}

.mobile-sidebar-close:hover {
    background: #e5e7eb;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .hamburger-btn,
    .mobile-sidebar,
    .mobile-sidebar-overlay,
    .mobile-search,
    header,
    .toast-container {
        display: none !important;
    }
}
