/* Speed Reader App - Tailwind CSS + Essential Custom Styles */

/* ===== THEME SYSTEM - CSS Custom Properties ===== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --sidebar-bg: #f9fafb;
    --word-display-bg: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #111827;
    --text-color: #f3f4f6;
    --border-color: #374151;
    --sidebar-bg: #1f2937;
    --word-display-bg: #1f2937;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
}

[data-theme="sepia"] {
    --bg-color: #f4f1e8;
    --text-color: #5c4b37;
    --border-color: #d4c4b0;
    --sidebar-bg: #ebe5d6;
    --word-display-bg: #faf8f3;
}

[data-theme="contrast"] {
    --bg-color: #000000;
    --text-color: #ffffff;
    --border-color: #ffffff;
    --sidebar-bg: #000000;
    --word-display-bg: #000000;
}

[data-theme="ocean"] {
    --bg-color: #001f3f;
    --text-color: #7fdbff;
    --border-color: #0074d9;
    --sidebar-bg: #002147;
    --word-display-bg: #002855;
    --primary-color: #39cccc;
    --primary-hover: #2aa1a1;
}

[data-theme="forest"] {
    --bg-color: #1a3626;
    --text-color: #a8e6a3;
    --border-color: #4a7c59;
    --sidebar-bg: #1f4029;
    --word-display-bg: #244831;
    --primary-color: #66bb6a;
    --primary-hover: #4caf50;
}

[data-theme="custom"] {
    /* Custom theme variables set via JavaScript */
}

/* ===== ESSENTIAL APP FUNCTIONALITY ===== */

/* Global theme application */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

/* Tab panel visibility control */
.tab-panel {
    display: none;
}

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

/* Tab content visibility control */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Word display specific styles */
.word-display {
    background-color: var(--word-display-bg);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.word-display.highlight-center .center-char {
    color: var(--primary-color);
    font-weight: 600;
}

/* Sidebar positioning */
.text-sidebar {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    transition: right 0.3s;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.text-sidebar.open {
    right: 0;
}

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

.modal.open {
    display: flex;
}

/* Sidebar word interaction */
.full-text .word {
    cursor: pointer;
    padding: 0.125rem 0.125rem;
    transition: background 0.2s;
    display: inline;
}

.full-text .word:hover {
    background: var(--primary-color);
    color: white;
    border-radius: 0.25rem;
}

.full-text .word.current {
    background: var(--primary-color);
    color: white;
    border-radius: 0.25rem;
    font-weight: 600;
}

/* Theme transitions for all elements */
* {
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* ===== LAYOUT AND SPACING ===== */

/* These styles are now handled by Tailwind classes in HTML */

/* Input panel styles - Some still needed for specific elements */
#textInput {
    font-family: inherit;
}

/* Button base styles - keeping minimal for functionality */
.btn {
    cursor: pointer;
    font-size: 0.875rem;
}

/* Upload area - styles handled by Tailwind */

/* Library styles - keeping only essential for JavaScript */

.book-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-color);
}

.book-item:hover {
    background: var(--sidebar-bg);
    box-shadow: var(--shadow);
}

.book-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.book-author {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Word display - keep essential theme-aware styles */
.word-display {
    background-color: var(--word-display-bg);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.word-display.highlight-center .center-char {
    color: var(--primary-color);
    font-weight: 600;
}

/* Keep only essential styles that Tailwind can't handle */

/* Sidebar text paragraph styles */
.text-paragraph {
    margin-bottom: 1rem;
    text-align: justify;
}

/* Modal styles - keeping essential structure */
.modal-content {
    background: var(--bg-color);
    border-radius: 0.5rem;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.settings-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.settings-group input[type="range"] {
    flex: 1;
}

.settings-group select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--bg-color);
    color: var(--text-color);
}

/* Theme presets grid */
.theme-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.theme-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-preset:hover {
    border-color: var(--primary-color);
}

.theme-preset.active {
    border-color: var(--primary-color);
    background: var(--sidebar-bg);
}

.theme-preview {
    width: 60px;
    height: 40px;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.theme-label {
    font-size: 0.75rem;
    color: var(--text-color);
}

/* Color settings grid */
.color-settings {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.color-setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.color-setting span {
    font-weight: 500;
    flex-shrink: 0;
    min-width: 120px;
}

.color-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1;
}

input[type="color"] {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    cursor: pointer;
    background: var(--bg-color);
}

input[type="text"].color-text {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-family: monospace;
    background: var(--bg-color);
    color: var(--text-color);
    max-width: 120px;
}

/* Font grid */
.font-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--sidebar-bg);
}

.font-option {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--bg-color);
    cursor: pointer;
    transition: all 0.2s;
}

.font-option:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.font-option.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.font-preview {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    color: var(--text-color);
}

.font-name {
    font-size: 0.75rem;
    opacity: 0.8;
    font-family: system-ui, -apple-system, sans-serif;
    color: var(--text-color);
}

.font-option.active .font-preview,
.font-option.active .font-name {
    color: white;
}

/* Button icon styles */
.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-color);
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 0.7;
}

/* Settings actions */
.settings-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 2rem;
    opacity: 0.7;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Responsive - sidebar width adjustment */
@media (max-width: 768px) {
    .text-sidebar {
        width: 100%;
        right: -100%;
    }
}