/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "微軟正黑體", sans-serif;
    background-color: #f5f7fa;
    color: #495057;
    min-height: 100vh;
}

/* Navigation Bar - Fixed Top */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #2c3e50;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

.navbar-brand {
    font-size: 18px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.school-indicator {
    padding: 4px 12px;
    background: rgba(41, 128, 185, 0.3);
    border: 1px solid #2980b9;
    border-radius: 4px;
    font-size: 14px;
    color: #74b9ff;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    color: white;
    font-size: 14px;
}

.logout-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Main Menu - Fixed Below Navbar */
.main-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    height: 50px;
    background: #FFFFFF;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    z-index: 999;
}

.menu-item {
    padding: 8px 16px;
    color: #5a6c7d;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    border: none;
    background: none;
}

.menu-item:hover {
    background: #f0f2f5;
    color: #2980b9;
}

.menu-item.active {
    background: #e8f4fd;
    color: #2980b9;
}

/* Content Area */
.content-area {
    padding-top: 110px;
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: 40px;
    max-width: 1600px;
    margin: 0 auto;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-subtitle {
    font-size: 14px;
    color: #7f8c8d;
}

/* Main Section (for hiding/showing) */
.main-section {
    display: none;
}

.main-section.active {
    display: block;
}

/* Statistics Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #FFFFFF;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid #2980b9;
    cursor: pointer;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #2980b9;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 16px;
    font-weight: 500;
    color: #2c3e50;
}

.stat-sublabel {
    font-size: 13px;
    color: #95a5a6;
    margin-top: 4px;
}

/* Content Sections */
.content-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.section {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #ecf0f1;
}

/* Resource List */
.resource-list {
    list-style: none;
}

.resource-item {
    padding: 12px 0;
    border-bottom: 1px solid #f1f3f5;
    cursor: pointer;
    transition: background 0.2s;
}

.resource-item:hover {
    background: #f8f9fa;
    margin: 0 -12px;
    padding: 12px;
}

.resource-item:last-child {
    border-bottom: none;
}

.resource-name {
    color: #2980b9;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.resource-meta {
    color: #7f8c8d;
    font-size: 12px;
}

/* Progress Bars */
.progress-item {
    margin-bottom: 16px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    color: #495057;
}

.progress-bar {
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    transition: width 0.3s;
}

/* Filter Controls */
.filter-controls {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 24px;
}

.search-box {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: #2980b9;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.data-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #5a6c7d;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e9ecef;
}

.data-table td {
    padding: 16px 12px;
    border-bottom: 1px solid #f1f3f5;
    font-size: 14px;
    color: #495057;
}

.data-table tr:hover {
    background: #f8f9fa;
    transition: background 0.2s;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #cce5ff;
    color: #004085;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    background: #f1f3f5;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    color: #6c757d;
}

.icon-btn:hover {
    background: #2980b9;
    color: white;
}

/* Charts Container */
.chart-container {
    position: relative;
    height: 300px;
    margin: 20px 0;
}

.chart-canvas {
    width: 100%;
    height: 100%;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #FFFFFF;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    color: #2c3e50;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #495057;
    font-weight: 500;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Priority Indicators */
.priority-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.priority-high {
    background: #e74c3c;
}

.priority-medium {
    background: #f39c12;
}

.priority-low {
    background: #27ae60;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #2980b9;
    color: white;
}

.btn-primary:hover {
    background: #21618c;
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: #2980b9;
    border: 1px solid #2980b9;
}

.btn-secondary:hover {
    background: #f8f9fa;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Export Button */
.export-btn {
    background: #27ae60;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.export-btn:hover {
    background: #229954;
    transform: translateY(-1px);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.page-btn {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
}

.page-btn:hover {
    background: #f8f9fa;
    border-color: #2980b9;
    color: #2980b9;
}

.page-btn.active {
    background: #2980b9;
    color: white;
    border-color: #2980b9;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2980b9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .content-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
    }

    .main-menu {
        padding: 0 16px;
        overflow-x: auto;
    }

    .content-area {
        padding-left: 16px;
        padding-right: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }

    .school-indicator {
        display: none;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

/* Report Types Radio Group */
.report-types {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.radio-item input[type="radio"] {
    cursor: pointer;
}

.radio-item label {
    cursor: pointer;
    font-size: 14px;
    color: #495057;
}

/* Time Range Badge */
.time-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #e8f4fd;
    color: #2980b9;
    border-radius: 4px;
    font-size: 13px;
    margin-left: 12px;
}

/* Class Card */
.class-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.class-status.active {
    background: #d4edda;
    color: #155724;
}

.class-status.ended {
    background: #e2e3e5;
    color: #383d41;
}

.class-status.ending-soon {
    background: #fff3cd;
    color: #856404;
}

/* Storage Bar */
.storage-bar {
    height: 24px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.storage-used {
    height: 100%;
    background: #2980b9;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* Resource Detail Container */
.resource-detail-container {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    gap: 20px;
    height: calc(100vh - 220px);
    overflow: hidden;
    max-height: 800px;
}

/* Resource Selector Panel */
.resource-selector-panel {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.panel-header h3 {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 12px;
}

.resource-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.resource-selector-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.resource-selector-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.resource-selector-item:hover {
    background: #f8f9fa;
    border-color: #2980b9;
}

.resource-selector-item.active {
    background: #e8f4fd;
    border-color: #2980b9;
    box-shadow: 0 2px 4px rgba(41, 128, 185, 0.1);
}

.resource-selector-icon {
    font-size: 24px;
    color: #6c757d;
}

.resource-selector-info {
    flex: 1;
    min-width: 0;
}

.resource-selector-title {
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resource-selector-meta {
    font-size: 12px;
    color: #7f8c8d;
}

.resource-selector-status {
    flex-shrink: 0;
}

/* Resource Detail Panel */
.resource-detail-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 12px;
    height: 100%;
    min-width: 0;
    width: 100%;
}

.detail-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    flex-shrink: 0;
    width: 100%;
}

.detail-card-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-card-header h3 {
    font-size: 16px;
    color: #2c3e50;
    margin: 0;
}

.detail-actions {
    display: flex;
    gap: 8px;
}

.detail-info-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.detail-info-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-info-item.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 15px;
    color: #2c3e50;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tag-item {
    display: inline-block;
    padding: 4px 12px;
    background: #e8f4fd;
    color: #2980b9;
    border-radius: 16px;
    font-size: 13px;
    margin-right: 8px;
    margin-bottom: 4px;
}

/* Statistics Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding: 20px;
    background: #f8f9fa;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: #2980b9;
    margin-bottom: 4px;
}

.stat-text {
    font-size: 13px;
    color: #6c757d;
}

.chart-wrapper {
    padding: 20px;
    height: 200px;
}

/* Usage Table */
.usage-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.usage-table th {
    background: #f8f9fa;
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: #5a6c7d;
    font-size: 12px;
    border-bottom: 2px solid #e9ecef;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.usage-table td {
    padding: 10px;
    border-bottom: 1px solid #f1f3f5;
    font-size: 13px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.usage-table tr:last-child td {
    border-bottom: none;
}

.usage-table tr:hover {
    background: #f8f9fa;
}

/* 針對資源詳細檢視的響應式設計 */
@media (max-width: 1400px) {
    .resource-detail-container {
        grid-template-columns: 320px minmax(0, 1fr);
    }
}

@media (max-width: 1200px) {
    .resource-detail-container {
        grid-template-columns: 280px minmax(0, 1fr);
        gap: 16px;
    }

    .detail-info-grid {
        padding: 16px;
        gap: 16px;
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 16px;
    }

    .stat-number {
        font-size: 24px;
    }

    .usage-table {
        font-size: 12px;
    }

    .usage-table th,
    .usage-table td {
        padding: 8px;
        font-size: 11px;
    }
}

@media (max-width: 992px) {
    .resource-detail-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .resource-selector-panel {
        max-height: 300px;
    }

    .resource-detail-panel {
        height: auto;
        overflow-y: visible;
    }

    .detail-info-grid {
        grid-template-columns: 1fr;
    }
}
