/* ===== CSS Variables (matching player design) ===== */
:root {
    /* Light mode - Child-friendly colors */
    --bg-primary: #fef7f0;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    --accent-color: #4299e1;
    --accent-hover: #3182ce;
    --border-color: #e2e8f0;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --danger-color: #fc8181;
    --danger-hover: #f56565;
    --success-color: #48bb78;
    --warning-color: #f6ad55;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1f2e;
        --bg-secondary: #252b3d;
        --bg-card: #2d3748;
        --text-primary: #f7fafc;
        --text-secondary: #cbd5e0;
        --text-muted: #a0aec0;
        --accent-color: #63b3ed;
        --accent-hover: #4299e1;
        --border-color: #4a5568;
        --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.4);
        --danger-color: #fc8181;
        --danger-hover: #f56565;
        --success-color: #68d391;
        --warning-color: #f6ad55;
    }
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Header ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn-back {
    padding: 10px 20px;
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

/* ===== Section ===== */
.section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* ===== Groups List ===== */
.groups-list {
    display: grid;
    gap: 16px;
}

.group-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.group-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-color);
}

.group-card.active {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(66, 153, 225, 0.05) 100%);
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.group-info {
    font-size: 13px;
    color: var(--text-secondary);
}

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

/* ===== Exercises List ===== */
.exercises-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .exercises-list {
        grid-template-columns: 1fr;
    }
}

.exercise-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
}

.exercise-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.exercise-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.exercise-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.exercise-files {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.file-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.file-badge.present {
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
}

.file-badge.missing {
    background: rgba(252, 129, 129, 0.1);
    color: var(--danger-color);
}

.exercise-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-large {
    max-width: 600px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-body label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.modal-body input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.modal-body input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px 24px;
}

/* ===== Upload Section ===== */
.upload-section {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.upload-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.upload-section input[type="file"] {
    display: block;
    margin-bottom: 12px;
    padding: 8px;
    font-size: 14px;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
}

.upload-status {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
}

.upload-status.success {
    display: block;
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
}

.upload-status.error {
    display: block;
    background: rgba(252, 129, 129, 0.1);
    color: var(--danger-color);
}

.upload-status.uploading {
    display: block;
    background: rgba(66, 153, 225, 0.1);
    color: var(--accent-color);
}

/* Checkbox label in upload sections */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
    cursor: pointer;
}

/* Upload progress bar */
.upload-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.upload-progress-bar .progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-color);
    border-radius: 3px;
    transition: width 0.2s ease;
}

/* ===== Subtitle Editor ===== */
.modal-editor {
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.subtitle-editor-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.subtitle-editor-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.subtitle-cue-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 55vh;
}

.subtitle-cue {
    display: grid;
    grid-template-columns: 40px 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
}

.subtitle-cue .cue-index {
    color: var(--text-muted);
    font-weight: 600;
    text-align: center;
}

.subtitle-cue input[type="text"] {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: monospace;
}

.subtitle-cue input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
}

.subtitle-cue .cue-time-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

.subtitle-cue .cue-time-group span {
    color: var(--text-muted);
}

.subtitle-cue .cue-text-input {
    grid-column: 1 / -1;
    margin-top: 4px;
}

.subtitle-cue .cue-text-input input {
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
}

.subtitle-cue .cue-text-input input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.subtitle-cue .cue-delete {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.subtitle-cue .cue-delete:hover {
    background: rgba(252, 129, 129, 0.15);
}

.subtitle-raw-edit {
    flex: 1;
    min-height: 200px;
    max-height: 55vh;
}

.subtitle-raw-edit textarea {
    width: 100%;
    height: 100%;
    min-height: 300px;
    padding: 12px;
    font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: vertical;
}

.subtitle-raw-edit textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay p {
    color: white;
    font-size: 16px;
    margin-top: 16px;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .section {
        padding: 16px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .group-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .exercise-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 16px;
    }
}

@media (max-width: 375px) {
    .header h1 {
        font-size: 20px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* ===== Tab Navigation ===== */
.tab-nav {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (max-width: 640px) {
    .tab-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
}

.tab-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Import Section ===== */
.import-container {
    max-width: 800px;
    margin: 0 auto;
}

.import-instructions {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.import-instructions h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 18px;
}

.import-instructions ul {
    list-style: none;
    padding: 0;
}

.import-instructions li {
    padding: 8px 0 8px 24px;
    color: var(--text-secondary);
    position: relative;
}

.import-instructions li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

.import-actions {
    text-align: center;
    padding: 40px;
}

.btn-large {
    padding: 16px 32px;
    font-size: 18px;
}

.import-progress {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-top: 24px;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--success-color));
    width: 0;
    transition: width 0.3s ease;
}

.import-log {
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-primary);
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
    font-family: monospace;
    font-size: 13px;
}

.log-entry {
    padding: 4px 0;
    color: var(--text-secondary);
}

.log-success {
    color: var(--success-color);
}

.log-error {
    color: var(--danger-color);
}

.log-info {
    color: var(--accent-color);
}

/* ===== Settings Section =====  */
.settings-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* iPad优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    .settings-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .info-table {
        font-size: 13px;
    }
    .info-table td {
        padding: 8px;
        word-break: break-word;
        overflow-wrap: break-word;
    }
}

/* 手机优化 */
@media (max-width: 767px) {
    .settings-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .info-table {
        font-size: 12px;
    }
    .info-table td {
        padding: 6px;
    }
}

.info-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.info-card h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table tr {
    border-bottom: 1px solid var(--border-color);
}

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

.info-table td {
    padding: 12px 8px;
    color: var(--text-secondary);
}

.info-table td:first-child {
    font-weight: 500;
    color: var(--text-primary);
    width: 40%;
}

.info-table td:last-child {
    font-family: monospace;
    font-size: 14px;
}

.info-card .btn {
    margin-right: 8px;
    margin-top: 8px;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.pagination .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

