/* CSS Variables */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-yellow: #fbbf24;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary-color);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn:active {
    transform: translateY(0);
}

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

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

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-icon {
    padding: 8px;
    background: transparent;
    font-size: 18px;
}

.btn-icon:hover {
    background: var(--bg-color);
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.icon {
    font-size: 16px;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Video Panel */
.video-panel {
    width: 45%;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 16px;
}

.video-container {
    flex: 1;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

#video-player {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-info {
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
}

.no-video {
    color: var(--text-secondary);
    font-style: italic;
}

.playback-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
}

/* Subtitle Panel */
.subtitle-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 8px;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.filter-tabs {
    display: flex;
    gap: 8px;
}

.tab {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.tab.active {
    background: var(--primary-color);
    color: white;
}

.search-box {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-box input {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: 200px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Subtitle List */
.subtitle-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 8px;
}

.empty-state .hint {
    font-size: 13px;
    opacity: 0.8;
}

/* Subtitle Item */
.subtitle-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.subtitle-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.subtitle-item.active {
    border-color: var(--primary-color);
    background: #f0f7ff;
}

.subtitle-item.important {
    border-left: 4px solid var(--accent-yellow);
}

.subtitle-item.has-note {
    border-left: 4px solid var(--accent-green);
}

.subtitle-item.has-image {
    border-left: 4px solid #8b5cf6;
    background: #f5f3ff;
}

.subtitle-item.has-image .subtitle-text {
    color: #5b21b6;
    font-weight: 500;
}

.subtitle-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #8b5cf6;
    color: white;
    font-size: 11px;
    border-radius: 10px;
    margin-left: 8px;
}

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

.sub-checkbox {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.subtitle-time {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
}

.subtitle-actions {
    display: flex;
    gap: 6px;
}

.subtitle-actions button {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-important {
    background: transparent;
    color: var(--accent-yellow);
}

.btn-important.active {
    background: var(--accent-yellow);
    color: white;
}

.btn-note {
    background: transparent;
    color: var(--accent-green);
}

.btn-note.active {
    background: var(--accent-green);
    color: white;
}

.btn-play {
    background: transparent;
    color: var(--primary-color);
}

.subtitle-text {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.subtitle-screenshots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.screenshot-thumb {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.screenshot-thumb:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

.subtitle-note {
    margin-top: 12px;
    padding: 10px;
    background: #f0fdf4;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #166534;
}

.subtitle-note .note-label {
    font-weight: 600;
    margin-right: 8px;
}

.subtitle-tags {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    padding: 2px 8px;
    background: var(--bg-color);
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Screenshot Bar */
.screenshot-bar {
    height: 100px;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 8px 16px;
    overflow-x: auto;
}

.screenshot-list {
    display: flex;
    gap: 8px;
    height: 100%;
    align-items: center;
}

.screenshot-list .screenshot-thumb {
    width: 140px;
    height: 80px;
    flex-shrink: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}

.modal-image {
    padding: 20px;
}

.modal-image img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
}

.modal-note, .modal-export, .modal-settings, .modal-find-replace {
    width: 500px;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    line-height: 1;
}

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

.modal-body {
    padding: 20px;
}

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

/* Note Modal */
#note-textarea {
    width: 100%;
    height: 150px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

#note-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.note-tags {
    margin-top: 12px;
}

.note-tags label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-right: 8px;
}

.note-tags input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

/* Export Modal */
.export-options {
    margin-bottom: 16px;
}

.export-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    cursor: pointer;
}

.export-options input[type="checkbox"],
.export-options input[type="radio"] {
    cursor: pointer;
}

/* Settings Modal */
.setting-item {
    margin-bottom: 16px;
}

.setting-item label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.setting-item input[type="text"],
.setting-item input[type="number"],
.setting-item select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.setting-item input:focus,
.setting-item select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.setting-item input[type="checkbox"] {
    margin-right: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }
    
    .video-panel {
        width: 100%;
        min-width: auto;
        height: 40vh;
    }
    
    .toolbar {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .toolbar-center {
        order: 3;
        width: 100%;
        justify-content: center;
    }
}

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chapter Title */
.chapter-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 12px 16px;
    background: var(--bg-color);
    border-left: 4px solid var(--primary-color);
    margin: 16px 0 8px 0;
}

/* Batch Edit Modal */
.modal-subtitle-edit {
    width: 600px;
    max-height: 80vh;
}

.edit-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.edit-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.edit-tab:hover {
    background: var(--bg-color);
}

.edit-tab.active {
    background: var(--primary-color);
    color: white;
}

.edit-panel {
    display: none;
}

.edit-panel.active {
    display: block;
}

.edit-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.edit-section:last-child {
    border-bottom: none;
}

.edit-section h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.edit-section .hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

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

.edit-row input[type="text"],
.edit-row input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.edit-row input[type="text"]:focus,
.edit-row input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.edit-row select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.edit-row.vertical input {
    margin-bottom: 8px;
}

.edit-options {
    display: flex;
    gap: 16px;
    margin: 8px 0;
}

.edit-options label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.quick-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

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

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

#replace-result {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
