/* ================================================================= */
/* === RESPONSIVE DESIGN - GLOBAL STYLESHEET === */
/* === Include this in all pages: <link href="/css/responsive.css" rel="stylesheet"> === */
/* ================================================================= */

/* === TABLET LANDSCAPE (max-width: 1024px) === */
@media (max-width: 1024px) {

    /* Layout */
    .page-layout,
    .content-layout {
        grid-template-columns: 1fr !important;
    }

    .sidebar,
    .right-sidebar,
    .featured-models-panel {
        display: none !important;
    }

    /* Header */
    .topgrid {
        padding: 0 20px;
    }

    /* Tables */
    .data-table,
    .admin-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td,
    .admin-table th,
    .admin-table td {
        padding: 10px 8px;
    }
}

/* === TABLET PORTRAIT (max-width: 768px) === */
@media (max-width: 768px) {

    /* Header */
    .topbar,
    .header {
        height: auto;
        min-height: 56px;
    }

    .topgrid {
        padding: 0 16px;
        height: 60px;
        grid-template-columns: auto 1fr auto;
    }

    .brand-text {
        font-size: 18px;
    }

    .nav,
    .header-nav {
        display: none;
    }

    /* Actions */
    .actions {
        gap: 8px;
    }

    .credits-display,
    .credits-pill,
    #navCredits {
        padding: 8px 14px !important;
        font-size: 14px !important;
    }

    /* Icon buttons */
    #messagesBtn,
    #rewardsBtn,
    #blogBtn,
    #postsBtn {
        width: 40px !important;
        height: 40px !important;
    }

    #messagesBtn svg,
    #rewardsBtn svg,
    #blogBtn svg,
    #postsBtn svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* User navigation */
    .usernav-chip {
        padding: 4px 10px;
    }

    .usernav-name {
        display: none;
    }

    /* Main content */
    .wrap {
        width: 100%;
        padding: 0 16px;
    }

    main,
    main.wrap {
        padding: 20px 16px;
    }

    /* Cards & Grids */
    .grid,
    .card-grid,
    .models-grid,
    #modelsGrid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }

    .pricing-grid,
    .bcm-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Forms */
    .filters {
        flex-wrap: wrap;
        gap: 10px;
    }

    .filters select,
    .filters input {
        flex: 1 1 45%;
        min-width: 140px;
    }

    /* Chat layout */
    .chat-layout {
        grid-template-columns: 240px 1fr !important;
    }

    .model-info-panel {
        display: none !important;
    }

    /* Tables - horizontal scroll */
    .table-container,
    .data-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table,
    .admin-table {
        min-width: 600px;
    }

    /* Footer */
    .footer .foot,
    .foot {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .foot-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Modals */
    .modal-box,
    .bcm-box,
    .credits-modal-container {
        width: 95% !important;
        max-width: 95% !important;
    }
}

/* === MOBILE (max-width: 600px) === */
@media (max-width: 600px) {

    /* Header */
    .topgrid {
        padding: 0 12px;
        height: 56px;
    }

    .brand-logo {
        width: 24px;
        height: 24px;
    }

    .brand-text {
        font-size: 16px;
    }

    /* Actions */
    .actions {
        gap: 6px;
    }

    #blogBtn {
        display: none !important;
    }

    .credits-display,
    .credits-pill,
    #navCredits {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }

    #messagesBtn,
    #rewardsBtn {
        width: 36px !important;
        height: 36px !important;
    }

    .usernav-role {
        display: none;
    }

    /* Main content */
    .wrap {
        padding: 0 12px;
    }

    main,
    main.wrap {
        padding: 16px 12px;
    }

    /* Typography */
    h1,
    .page-title,
    .section-title {
        font-size: 24px !important;
    }

    h2 {
        font-size: 20px !important;
    }

    h3 {
        font-size: 18px !important;
    }

    /* Cards & Grids - single column */
    .grid,
    .card-grid,
    .models-grid,
    #modelsGrid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .pricing-grid,
    .bcm-grid {
        grid-template-columns: 1fr !important;
    }

    /* Forms */
    .filters {
        flex-direction: column;
    }

    .filters select,
    .filters input,
    .filters button {
        width: 100%;
    }

    .field,
    .form-group {
        margin-bottom: 12px;
    }

    .input,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Chat layout - full width */
    .chat-layout {
        grid-template-columns: 1fr !important;
    }

    .convo-list {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
        background: white;
    }

    .message-wrapper {
        max-width: 90%;
    }

    .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }

    /* Cards */
    .card,
    .post,
    .model-card {
        border-radius: 12px;
    }

    .card-header,
    .post-header {
        padding: 12px;
    }

    .card-body,
    .post-content {
        padding: 14px;
    }

    /* Buttons */
    .btn,
    button {
        min-height: 44px;
        /* Touch-friendly */
    }

    .btn-group {
        flex-direction: column;
        gap: 8px;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Modals - almost fullscreen */
    .modal-box,
    .bcm-box,
    .credits-modal-container {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 90vh;
    }

    .modal-header,
    .bcm-header {
        padding: 16px;
    }

    .modal-body,
    .bcm-body {
        padding: 16px;
    }

    /* Tables */
    .data-table,
    .admin-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td,
    .admin-table th,
    .admin-table td {
        padding: 8px 6px;
    }

    /* Footer */
    .footer {
        padding: 16px 12px;
    }

    .foot {
        font-size: 13px;
    }
}

/* === MOBILE SMALL (max-width: 480px) === */
@media (max-width: 480px) {
    .topgrid {
        padding: 0 10px;
    }

    .brand-text {
        font-size: 15px;
    }

    .credits-display,
    .credits-pill,
    #navCredits {
        padding: 5px 8px !important;
        font-size: 12px !important;
    }

    h1,
    .page-title {
        font-size: 22px !important;
    }

    /* Post layout */
    .post-body-container.has-image {
        flex-direction: column;
    }

    .post-media-side {
        width: 100%;
        height: 250px;
    }
}

/* === EXTRA SMALL (max-width: 360px) === */
@media (max-width: 360px) {
    .topgrid {
        padding: 0 8px;
    }

    .brand-text {
        font-size: 14px;
    }

    .credits-display,
    .credits-pill,
    #navCredits {
        padding: 4px 6px !important;
        font-size: 11px !important;
    }

    #messagesBtn,
    #rewardsBtn {
        width: 32px !important;
        height: 32px !important;
    }

    h1,
    .page-title {
        font-size: 20px !important;
    }
}

/* === ADMIN SPECIFIC === */

/* Hide sidebar on tablet and below for admin */
@media (max-width: 1024px) {

    /* Admin layout - single column */
    .layout {
        grid-template-columns: 1fr !important;
        display: block !important;
    }

    /* Hide sidebar - all possible selectors */
    .layout>.sidebar,
    .layout>aside,
    .layout aside.sidebar,
    aside.sidebar,
    .sidebar {
        display: none !important;
    }

    /* Content full width */
    .layout>.content,
    .layout>main,
    main.content,
    .content {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Show hamburger menu button */
    .mobile-sidebar-toggle {
        display: flex !important;
    }
}

@media (max-width: 768px) {

    /* Admin sidebar - off-canvas */
    .layout>.sidebar,
    .admin-sidebar,
    .sidebar-nav {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        height: 100vh !important;
        width: 280px !important;
        z-index: 9999 !important;
        transition: left 0.3s ease !important;
        background: #101215 !important;
        display: flex !important;
        flex-direction: column !important;
        padding-top: 80px !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5) !important;
    }

    .layout>.sidebar.open,
    .admin-sidebar.open,
    .sidebar-nav.open {
        left: 0 !important;
    }

    /* Admin content - full width */
    .layout>.content,
    .admin-content,
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 20px 16px !important;
    }

    /* Admin header */
    .admin-header {
        padding: 12px 16px;
    }

    /* Topgrid for admin */
    .topgrid {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    /* Stats cards - 2 columns */
    .stats-grid,
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 16px !important;
    }

    .stat-value {
        font-size: 24px !important;
    }

    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
    }

    /* Welcome banner */
    .welcome-banner {
        flex-direction: column !important;
        text-align: center !important;
        padding: 20px !important;
    }

    /* Two column grid */
    .two-column-grid {
        grid-template-columns: 1fr !important;
    }

    /* Sections */
    .section {
        padding: 20px !important;
    }

    /* Admin usernav */
    .usernav-chip span:not(.usernav-avatar):not(.admin-badge) {
        display: none !important;
    }

    .admin-badge {
        display: none !important;
    }

    /* Form layouts */
    .form-row,
    .input-row {
        flex-direction: column;
        gap: 12px;
    }

    .form-row>*,
    .input-row>* {
        width: 100% !important;
    }
}

@media (max-width: 480px) {

    /* Stats - single column */
    .stats-grid,
    .dashboard-stats {
        grid-template-columns: 1fr !important;
    }

    /* Hide brand text */
    .brand-text {
        display: none !important;
    }

    /* Content padding */
    .layout>.content,
    .content {
        padding: 16px 12px !important;
    }

    /* Page title */
    h1 {
        font-size: 24px !important;
    }

    /* Quick actions grid */
    [style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* === UTILITY CLASSES === */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    padding: 8px;
    background: none;
    border: none;
    color: currentColor;
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}