/* --- responsive.css --- */
/* --- Responsive Design --- */
.sidebar-toggle {
    display: none; /* Hide by default on larger screens */
    position: fixed;
    top: 15px;  /* Adjusted: Moved slightly up */
    left: 10px; /* Adjusted: Moved slightly left */
    z-index: 1100; /* Above sidebar and overlay */
    background: var(--sidebar-bg);
    color: var(--primary-color); /* Use primary color */
    border: 1px solid var(--border-color); /* Add border */
    font-size: 1.5em;
    padding: 5px 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.2s, color 0.2s;
}
.sidebar-toggle:hover {
    background-color: var(--background-color);
}

.overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999; /* Below sidebar, above content */
    opacity: 0; /* Start transparent */
    visibility: hidden; /* Start hidden */
    transition: opacity 0.3s ease, visibility 0s linear 0.3s; /* Fade out */
}
.overlay.active {
    display: block; /* Show when active */
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s; /* Fade in */
}

/* --- Tablet Landscape & Portrait Common (e.g., <= 1024px) --- */
@media (max-width: 1024px) {
    .cms-container {
        display: block; /* Change from flex to block for simpler fixed sidebar handling */
    }

    .sidebar {
        position: fixed; /* Ensure it's fixed for transform */
        height: 100%;
        left: 0;
        top: 0;
        transform: translateX(-100%); /* Hidden by default */
        transition: transform var(--transition-speed-normal) var(--transition-easing);
    }

    .sidebar.open {
        transform: translateX(0); /* Slide in when open */
    }

    .main-content {
        width: 100%; /* Take full width */
        margin-left: 0; /* Reset margin */
        padding: 20px; /* Adjust padding */
    }

    .content-header {
        width: 100%; /* Full width */
        margin-left: 0; /* Reset margin */
        padding: 15px 20px;
        position: sticky; /* Keep header sticky */
        top: 0;
        background-color: var(--surface-color); /* Ensure background */
        z-index: 900;
    }

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

    /* Dashboard Grid */
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Adjust minmax */
        gap: 15px;
    }

    /* Tables */
    .table-container {
        overflow-x: auto; /* Enable horizontal scroll */
        -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
    }
    .data-table {
         min-width: 700px; /* Adjust min-width as needed */
    }
    .data-table th, .data-table td {
         padding: 10px 12px; /* Adjust padding */
         font-size: 0.9em; /* Adjust font size */
         white-space: nowrap; /* Prevent wrapping to force horizontal scroll */
     }

    /* Hide specific columns in Analytics Artwork table for tablet */
    #analytics-content .data-table th:nth-child(3), /* 총 조회수 Header */
    #analytics-content .data-table td:nth-child(3), /* 총 조회수 Data */
    #analytics-content .data-table th:nth-child(5), /* AR 실행 수 Header */
    #analytics-content .data-table td:nth-child(5) { /* AR 실행 수 Data */
        display: none;
    }
    /* Add rules here to hide columns in other tables if needed for tablets */


    /* AR Editor */
    .ar-editor-layout {
        flex-direction: column; /* Stack vertically */
        gap: 20px; /* Adjust gap for vertical layout */
    }
    .marker-preview-container,
    .ar-editor-area {
        width: 100%;
        flex-basis: auto; /* Reset basis */
        max-width: none;
    }
    .marker-preview-container {
        max-height: 250px;
        text-align: center; /* Center marker preview */
    }
     #marker-preview-img {
         max-width: 70%; /* Adjust marker size in preview */
     }
     .ar-scene-preview {
         min-height: 300px;
         width: 100%; /* Allow preview to take more width */
         max-width: 320px; /* Limit max width */
         margin: 0 auto; /* Center it */
    }
    .ar-editor-area {
        align-items: stretch; /* Ensure controls take full width */
    }
    .ar-element-controls { /* Make control sections full width */
        width: 100%;
    }
}


/* --- Smaller Tablets / Portrait (e.g., <= 850px) --- */
@media (max-width: 850px) {
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Allow slightly larger cards */
    }

    /* Form rows stack earlier */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .form-row .form-group {
         margin-bottom: 15px;
    }

     /* AR Editor List Items */
     #ar-image-list li, #ar-effect-image-list li {
          /* Adjustments if needed */
     }
     .ar-element-pos-controls {
          /* Adjustments if needed */
     }
     .ar-element-actions {
          /* Adjustments if needed */
     }
}


/* --- Mobile (e.g., <= 767px, refining styles from 1024px) --- */
@media (max-width: 767px) {
    :root { /* Adjust some base values for mobile */
        --content-padding: 16px;
        --base-padding: 16px;
        --h1-font-size: 1.6rem;
        --h2-font-size: 1.3rem;
        --body-font-size: 0.9rem;
        --small-font-size: 0.8rem;
    }

    .main-content {
        padding: var(--content-padding);
    }
    .content-header {
        padding: 10px var(--content-padding);
    }

    .content-section {
        padding: var(--base-padding);
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .section-header h2 {
        font-size: 1.2em; /* Slightly smaller heading */
    }

    /* Dashboard */
    .dashboard-grid { grid-template-columns: 1fr; } /* Ensure 1 column */
    .stat-card .value { font-size: 1.6em; }

    /* Tables */
    .data-table {
         min-width: unset; /* Remove min-width for mobile */
    }
    .data-table th, .data-table td {
        padding: 8px 10px; /* Adjust padding */
        font-size: 0.85em; /* Adjust font size */
        white-space: normal; /* Allow wrapping on mobile */
        vertical-align: top; /* Align top when wrapping */
    }
    /* Hide more table columns for mobile */
     .exhibition-table th:nth-child(3), .exhibition-table td:nth-child(3), /* 기간 */
     .exhibition-table th:nth-child(5), .exhibition-table td:nth-child(5), /* 컬렉션수 */
     .artworks-table th:nth-child(5), .artworks-table td:nth-child(5), /* 소속프로젝트 */
     .user-table th:nth-child(3), .user-table td:nth-child(3), /* 역할 */
     .user-table th:nth-child(5), .user-table td:nth-child(5) { /* 등록일 */
         display: none;
     }
     /* Ensure Analytics columns hidden on tablet are also hidden here */
     #analytics-content .data-table th:nth-child(3), /* 총 조회수 */
     #analytics-content .data-table td:nth-child(3),
     #analytics-content .data-table th:nth-child(5), /* AR 실행 수 */
     #analytics-content .data-table td:nth-child(5) {
         display: none;
     }
     /* Optionally hide more analytics columns for mobile */
     #analytics-content .data-table th:nth-child(4), /* 평균 체류 시간 */
     #analytics-content .data-table td:nth-child(4),
     #analytics-content .data-table th:nth-child(6), /* 상호작용률 */
     #analytics-content .data-table td:nth-child(6) {
          display: none;
     }
     /* Recommendation column might need specific mobile styling if kept */
     #analytics-content .data-table .recommendation-cell {
         font-size: 0.8em; /* Smaller font */
         min-height: unset; /* Remove min-height */
     }


     .table-controls {
         flex-direction: column;
         align-items: stretch;
     }

    /* Forms */
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    .form-actions .btn {
        width: 100%;
    }

    /* AR Editor */
     .marker-preview-container { max-height: 200px; }
     .ar-scene-preview { min-height: 280px; max-width: 280px; }
     #ar-image-list li, #ar-effect-image-list li { flex-direction: column; align-items: flex-start;}
     .ar-element-info { flex-basis: 100%; }
     .ar-element-name { margin-top: 5px; }
     .ar-element-pos-controls { width: auto; }
     .ar-element-actions { width: 100%; text-align: right; margin-top: 5px;}
}