/* ==========================================
   來亞保險私塾 Podcast 生成器 - 樣式表
   ========================================== */

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-sidebar: #1f2937;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --sidebar-width: 250px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans TC', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ==========================================
   App Layout - 側邊欄式設計
   ========================================== */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Auth Section */
.auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
}

.user-info span {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.google-icon {
    margin-right: 0.5rem;
}

/* ==========================================
   Sidebar - 側邊欄
   ========================================== */

.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - 60px);
    background: var(--bg-sidebar);
    color: #fff;
    overflow-y: auto;
    z-index: 90;
    display: flex;
    flex-direction: column;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.5);
    padding: 1rem 1rem 0.5rem;
    margin-top: 0.5rem;
}

.sidebar-section-title:first-child {
    margin-top: 0;
}

.sidebar-category-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    gap: 0.75rem;
}

.sidebar-category-item:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-category-item.active {
    background: var(--primary-color);
}

.category-icon {
    font-size: 1rem;
    opacity: 0.8;
}

.category-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-edit-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
    opacity: 0;
}

.sidebar-category-item:hover .category-edit-btn {
    opacity: 1;
}

.category-edit-btn:hover {
    color: #fff;
}

.sidebar-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 1rem;
    background: rgba(255,255,255,0.1);
    border: 1px dashed rgba(255,255,255,0.3);
    border-radius: var(--radius-md);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.sidebar-add-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-toggle-section {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    color: rgba(255,255,255,0.7);
    font-size: 0.875rem;
    gap: 0.5rem;
    border-radius: var(--radius-md);
    transition: background 0.15s;
}

.sidebar-toggle-section:hover {
    background: rgba(255,255,255,0.1);
}

.toggle-icon {
    font-size: 0.75rem;
}

/* ==========================================
   Main Panel - 主面板
   ========================================== */

.main-panel {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-top: 60px;
    padding: 2rem;
    min-height: calc(100vh - 60px);
    overflow-y: auto;
}

.main-panel-inner {
    max-width: 900px;
    margin: 0 auto;
}

/* Section Cards */
.section-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.section-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Category Selection Row */
.category-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.category-row label {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.category-row select {
    flex: 1;
    max-width: 300px;
}

/* ==========================================
   Form Elements
   ========================================== */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
    line-height: 1.6;
}

.form-textarea.large {
    min-height: 200px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.375rem;
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 1.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
}

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

/* Role Settings */
.role-settings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.role-card {
    background: var(--bg-primary);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
}

.role-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.role-card-title .role-icon {
    font-size: 1.25rem;
}

/* Range Slider */
.range-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.range-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: transform 0.15s;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.range-value {
    min-width: 50px;
    text-align: right;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Prompt Container */
.prompt-container {
    position: relative;
}

.prompt-container.expanded .form-textarea {
    min-height: 400px;
}

.prompt-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Advanced Settings */
.advanced-settings-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: color 0.15s;
}

.advanced-settings-toggle:hover {
    color: var(--text-primary);
}

.advanced-settings-panel {
    display: none;
    padding-top: 1rem;
}

.advanced-settings-panel.open {
    display: block;
}

/* ==========================================
   Buttons
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    gap: 0.5rem;
}

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

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary.has-changes {
    animation: pulse-primary 2s infinite;
}

@keyframes pulse-primary {
    0%, 100% { box-shadow: var(--shadow-md); }
    50% { box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.3); }
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-primary);
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
}

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

.spinner-dark {
    border-color: rgba(0,0,0,0.1);
    border-top-color: var(--primary-color);
}

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

/* ==========================================
   Drop Zone & File Upload
   ========================================== */

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    text-align: center;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.25s ease;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.03);
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.08);
    transform: scale(1.01);
}

.drop-zone-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.7;
}

.drop-text {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.drop-subtext {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* File List */
.file-list-container {
    margin-top: 1.25rem;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.file-list-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.file-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.file-item:last-child { margin-bottom: 0; }

.file-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.file-icon { font-size: 1.125rem; }

.file-name {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.file-remove {
    background: none;
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.25rem;
    transition: color 0.15s;
    flex-shrink: 0;
}

.file-remove:hover { color: var(--error-color); }

/* ==========================================
   Action Section
   ========================================== */

.action-section {
    text-align: center;
    padding: 1.5rem 0;
}

/* ==========================================
   Progress Section
   ========================================== */

.progress-section { margin-top: 1.5rem; }

.progress-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.progress-card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
}

.progress-bar-container {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-status {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    opacity: 0.4;
    transition: opacity 0.25s;
}

.step.active, .step.completed { opacity: 1; }

.step-indicator {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.25s;
}

.step.active .step-indicator {
    background: var(--primary-gradient);
    color: white;
}

.step.completed .step-indicator {
    background: var(--success-color);
    color: white;
}

.step.completed .step-indicator::after {
    content: '\2713';
    font-size: 0.875rem;
}

.step.completed .step-indicator { font-size: 0; }

.step span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==========================================
   Result Section
   ========================================== */

.result-section, .error-section { margin-top: 1.5rem; }

.result-card {
    text-align: center;
    padding: 2.5rem 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.result-card.success {
    background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(5,150,105,0.08));
    border: 1px solid rgba(16,185,129,0.2);
}

.result-card.error {
    background: linear-gradient(135deg, rgba(239,68,68,0.08), rgba(220,38,38,0.08));
    border: 1px solid rgba(239,68,68,0.2);
}

.result-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
}

.result-card h2 {
    font-size: 1.375rem;
    margin-bottom: 0.5rem;
}

.result-card p {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==========================================
   Modal
   ========================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.25rem;
    line-height: 1;
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ==========================================
   Toast Notifications
   ========================================== */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast-success { background: var(--success-color); }
.toast-error { background: var(--error-color); }
.toast-warning { background: var(--warning-color); }
.toast-info { background: var(--primary-color); }

.toast-icon {
    font-size: 1rem;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: white;
}

.toast.fade-out {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    to { transform: translateX(100%); opacity: 0; }
}

/* ==========================================
   Unsaved Indicator
   ========================================== */

.unsaved-indicator {
    display: none;
    font-size: 0.75rem;
    color: var(--warning-color);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.unsaved-indicator.show {
    display: inline-block;
}

/* ==========================================
   Global Loader
   ========================================== */

.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.loader-message {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* ==========================================
   Login Required
   ========================================== */

.login-required {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 350px;
}

.login-card {
    text-align: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.login-icon {
    font-size: 3.5rem;
    margin-bottom: 1.25rem;
}

.login-card h2 {
    font-size: 1.375rem;
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-secondary);
}

/* ==========================================
   Footer
   ========================================== */

.footer {
    padding: 1.25rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: 0.8125rem;
}

/* ==========================================
   Utility Classes
   ========================================== */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        display: none;
    }

    .sidebar.mobile-open {
        display: flex;
        width: 280px;
        z-index: 150;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 140;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-panel {
        margin-left: 0;
        padding: 1rem;
    }

    .header {
        padding: 0 1rem;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-primary);
    }

    .role-settings {
        grid-template-columns: 1fr;
    }

    .category-row {
        flex-direction: column;
        align-items: stretch;
    }

    .category-row select {
        max-width: none;
    }

    .progress-steps {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .step { flex: 0 0 45%; }

    .btn-large { width: 100%; }

    .result-actions { flex-direction: column; }
    .result-actions .btn { width: 100%; }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        max-width: none;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}
