/**
 * Mobile Responsive Styles for Creator Theme Stack
 * Breakpoints: 992px, 768px, 748px (all columns 100% width)
 * Focus: Flex layouts for responsive design
 */

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Large tablets and small desktops (992px and below) */
@media (max-width: 992px) {
    /* Container adjustments */
    .container {
        max-width: 100%;
        padding: 0 20px;
    }
    
    /* Header responsive */
    .cs-header {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .cs-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
    
    /* Form layouts become more compact */
    .cs-form-row {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .cs-form-group {
        width: 100%;
    }
    
    /* Admin panel tables */
    .cs-admin-table {
        display: flex;
        flex-direction: column;
    }
    
    .cs-admin-table thead {
        display: none;
    }
    
    .cs-admin-table tbody {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .cs-admin-table tr {
        display: flex;
        flex-direction: column;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 15px;
        background: #f9f9f9;
    }
    
    .cs-admin-table td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }
    
    .cs-admin-table td:before {
        content: attr(data-label);
        font-weight: bold;
        flex-basis: 50%;
    }
    
    /* Button groups */
    .cs-btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .cs-btn {
        width: 100%;
        text-align: center;
    }
    
    /* Cards and panels */
    .cs-card {
        margin-bottom: 20px;
    }
    
    .cs-stats-grid {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .cs-stat-card {
        width: 100%;
    }
}

/* Tablets (992px and below) */
@media (max-width: 992px) {
    /* Images responsive */
    img {
        max-width: 100%;
    }

    /* Dashboard tabs responsive */
    .cs-dashboard-tabs {
        flex-flow: row wrap;
    }

    .cs-dashboard-tab-btn {
        width: auto !important;
        max-width: unset !important;
        white-space: nowrap;
        flex: unset !important;
    }

    /* Tables responsive */
    #dashboard-submissions-table *,
    #submissions-table * {
        font-size: 14px;
    }

    .cs-sortable-header {
        width: 33.3333% !important;
    }

    /* Submission detail */
    .cs-submission-detail h2 {
        width: 100%;
    }

    .cs-text-center + div {
        flex-flow: row wrap;
    }

    .cs-grid-layout {
        display: flex !important;
        flex-flow: column !important;
    }

    /* Message forms */
    #creator-message-form > div {
        flex-flow: column;
    }

    #admin-message-content,
    #creator-message-content {
        flex: unset;
        width: 100% !important;
        min-height: 200px !important;
    }

    .cs-input-group {
        flex-flow: column;
    }

    /* Dashboard height adjustments */
    #submit-work-tab,
    .cs-dashboard {
        height: auto !important;
        max-height: unset !important;
    }

    .cs-form-step {
        max-height: unset !important;
    }

    /* Typography scaling */
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    
    /* Navigation becomes hamburger-friendly */
    .cs-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .cs-nav-item {
        width: 100%;
        text-align: center;
        padding: 12px 0;
        border-bottom: 1px solid #eee;
    }
    
    /* Form sections stack */
    .cs-form-section {
        margin-bottom: 25px;
    }
    
    .cs-form-section-header {
        margin-bottom: 15px;
    }
    
    /* Checkbox and radio groups */
    .cs-checkbox-group {
        flex-direction: column;
        gap: 12px;
    }
    
    .cs-radio-group {
        flex-direction: column;
        gap: 12px;
    }
    
    /* File upload areas */
    .cs-file-upload {
        padding: 20px;
        text-align: center;
    }
    
    /* Status badges and small elements */
    .cs-status-badge {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    /* Dashboard grid adjustments */
    .cs-dashboard-grid {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    
    .cs-dashboard-card {
        width: 100%;
    }
    
    /* Submission detail adjustments */
    .cs-submission-header {
        display: flex;
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .cs-submission-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    /* Modal adjustments */
    .cs-modal-content {
        width: 95%;
        max-width: none;
        margin: 10px auto;
    }
}

/* Mobile (748px and below) - All columns 100% width */
@media (max-width: 748px) {
    /* Force all columns to full width */
    .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
    .col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
    .cs-col, .cs-column, .column {
        width: 100% !important;
        flex: none !important;
        max-width: 100% !important;
    }
    
    /* Container full width with minimal padding */
    .container, .cs-container {
        width: 100%;
        max-width: 100%;
        padding: 0 15px;
        margin: 0 auto;
    }
    
    /* All flex containers stack vertically */
    .cs-flex-row, .flex-row, .row {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px;
    }
    
    /* Headers and titles */
    h1 { font-size: 22px; line-height: 1.3; }
    h2 { font-size: 18px; line-height: 1.4; }
    h3 { font-size: 16px; line-height: 1.4; }
    
    /* Navigation full width */
    .cs-header-nav, .cs-main-nav {
        width: 100%;
    }
    
    /* Form elements full width */
    .cs-form-control, .form-control, input, select, textarea {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Button groups stack */
    .cs-btn-group, .btn-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .cs-btn, .btn {
        width: 100%;
        margin-bottom: 8px;
        font-size: 14px;
        padding: 10px 15px;
    }
    
    /* Tables become card-like on mobile */
    .cs-table-responsive {
        overflow-x: visible;
    }
    
    .cs-admin-table, .cs-table {
        width: 100%;
        border: none;
    }
    
    .cs-admin-table tr {
        display: block;
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 15px;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .cs-admin-table th,
    .cs-admin-table td {
        display: block;
        width: 100%;
        text-align: left;
        border: none;
        padding: 8px 0;
    }
    
    .cs-admin-table th {
        display: none;
    }
    
    .cs-admin-table td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        color: #666;
    }

    /* ========================================
       SUBMISSION TABLES - CARD LAYOUT (TESTING)
       ** TO REMOVE: Delete from here to "END SUBMISSION TABLES" **
       ======================================== */

    /* Apply card layout to submission tables */
    .cs-submissions-container {
        overflow-x: visible;
    }

    .cs-submissions-table,
    .cs-submissions-list {
        display: block;
        width: 100%;
        border: none;
    }

    .cs-submissions-table thead,
    .cs-submissions-list thead {
        display: none; /* Hide headers on mobile */
    }

    .cs-submissions-table tbody,
    .cs-submissions-list tbody {
        display: block;
    }

    .cs-submissions-table tr,
    .cs-submissions-list tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 15px;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .cs-submissions-table td,
    .cs-submissions-list td {
        display: block;
        width: 100%;
        padding: 10px 0;
        border-bottom: 1px solid #eee;
        border: none;
        text-align: left;
    }

    .cs-submissions-table td:last-child,
    .cs-submissions-list td:last-child {
        border-bottom: none;
    }

    .cs-submissions-table td:before,
    .cs-submissions-list td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: inline;
        color: #333;
        margin-right: 5px;
    }

    /* Action buttons in submission tables */
    .cs-submissions-table .cs-btn,
    .cs-submissions-list .cs-btn {
        font-size: 12px;
        padding: 6px 12px;
        white-space: nowrap;
    }

    /* Status badges in cards */
    .cs-submissions-table .cs-status-badge,
    .cs-submissions-list .cs-status-badge {
        margin-left: auto;
    }

    /* ========================================
       END SUBMISSION TABLES (TESTING)
       ======================================== */

    /* Status and metadata info */
    .cs-meta-info {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .cs-status-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }
    
    /* File upload areas */
    .cs-file-upload-area {
        padding: 20px 15px;
        text-align: center;
        border: 2px dashed #ccc;
        border-radius: 8px;
        margin: 15px 0;
    }
    
    /* Progress bars */
    .cs-progress {
        width: 100%;
        margin: 10px 0;
    }
    
    /* Modal full screen on mobile */
    .cs-modal {
        padding: 0;
    }
    
    .cs-modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .cs-modal-header {
        padding: 15px;
        border-bottom: 1px solid #eee;
    }
    
    .cs-modal-body {
        padding: 15px;
        overflow-y: auto;
        flex: 1;
    }
    
    /* Cards full width */
    .cs-card {
        width: 100%;
        margin-bottom: 15px;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .cs-card-header {
        padding: 15px;
        border-bottom: 1px solid #eee;
    }
    
    .cs-card-body {
        padding: 15px;
    }
    
    /* Stats display */
    .cs-stats-grid {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .cs-stat-card {
        width: 100%;
        padding: 15px;
        text-align: center;
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Submission metadata */
    .cs-submission-meta {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .cs-meta-group {
        padding: 12px 0;
        border-bottom: 1px solid #eee;
    }
    
    .cs-meta-label {
        font-weight: bold;
        color: #666;
        font-size: 14px;
        margin-bottom: 4px;
        display: block;
    }
    
    .cs-meta-value {
        font-size: 15px;
        color: #333;
    }
    
    /* Search and filter forms */
    .cs-search-form {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .cs-filter-row {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    /* Pagination */
    .cs-pagination {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
        margin: 20px 0;
    }
    
    .cs-pagination a,
    .cs-pagination span {
        padding: 8px 12px;
        margin: 2px;
        font-size: 14px;
    }
    
    /* Footer adjustments */
    .cs-footer {
        padding: 20px 15px;
        text-align: center;
    }
    
    .cs-footer-links {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    /* Utility classes for mobile */
    .mobile-hide {
        display: none !important;
    }
    
    .mobile-show {
        display: block !important;
    }
    
    .mobile-center {
        text-align: center !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    /* Touch-friendly interactions */
    .cs-btn, .btn, button {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
    
    /* Improved spacing for mobile */
    .cs-section {
        margin-bottom: 25px;
    }
    
    .cs-form-section {
        margin-bottom: 20px;
        padding: 15px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    /* Loading states */
    .cs-loading {
        text-align: center;
        padding: 40px 20px;
    }
    
    .cs-spinner {
        width: 40px;
        height: 40px;
        margin: 0 auto 15px;
    }
}

/* ========================================
   MOBILE-SPECIFIC COMPONENTS
   ======================================== */

/* Mobile navigation toggle */
@media (max-width: 768px) {
    .cs-mobile-nav-toggle {
        display: block;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        padding: 10px;
    }
    
    .cs-nav-mobile {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #eee;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        z-index: 1000;
    }
    
    .cs-nav-mobile.active {
        display: block;
    }
    
    .cs-nav-mobile .cs-nav-item {
        display: block;
        padding: 15px 20px;
        border-bottom: 1px solid #eee;
    }
    
    .cs-nav-mobile .cs-nav-item:last-child {
        border-bottom: none;
    }

    /* Custom header and container adjustments */
    .site-header .container {
        flex-flow: column;
    }

    .container,
    div.container,
    main .container {
        padding: 15px !important;
    }

    #profile-view-mode > div > div {
        display: flex !important;
        flex-flow: column !important;
    }

    .site-main {
        min-height: unset !important;
        padding: 20px 0 !important;
    }

    /* Remove min-heights from dashboard content */
    .cs-dashboard-tab-content {
        min-height: unset !important;
        max-height: none !important;
        height: auto !important;
        padding: 20px !important;
    }

    /* Force hidden tabs to truly collapse and not affect layout */
    .cs-dashboard-tab-content:not(.active) {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        left: -9999px !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Force active tab to only use its content height */
    .cs-dashboard-tab-content.active {
        display: block !important;
        position: relative !important;
        visibility: visible !important;
        left: auto !important;
        height: auto !important;
    }

    /* Force natural height for form steps and containers */
    .cs-form-container,
    .cs-dashboard,
    #submit-work-tab {
        min-height: unset !important;
        height: auto !important;
        max-height: none !important;
    }

    /* Force inactive form steps to truly collapse and not affect layout */
    .cs-form-step:not(.active) {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        left: -9999px !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Force active form step to only use its content height */
    .cs-form-step.active {
        display: block !important;
        visibility: visible !important;
        position: relative !important;
        left: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Hide messages inside inactive tabs */
    .cs-dashboard-tab-content:not(.active) .cs-message,
    .cs-dashboard-tab-content:not(.active) .cs-form-container .cs-message {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        left: -9999px !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Force container and dashboard to only use active content height */
    .container,
    .cs-dashboard {
        height: auto !important;
        min-height: unset !important;
    }
}

/* ========================================
   PRINT STYLES (BONUS)
   ======================================== */
@media print {
    .cs-no-print {
        display: none !important;
    }
    
    .cs-print-full-width {
        width: 100% !important;
    }
    
    .cs-admin-table {
        border-collapse: collapse;
    }
    
    .cs-admin-table th,
    .cs-admin-table td {
        border: 1px solid #000;
        padding: 8px;
    }
}