/* ============================================
   LEGGERE LIBRI - Main Styles
   ============================================ */

/* CSS Variables - Theme System */
:root {
    /* Dark theme (default) */
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-elevated: #1a1a1a;
    --bg-card: #181818;
    --bg-card-hover: #212121;
    --bg-input: #242424;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #6a6a6a;
    --accent: #1DB954;
    --accent-hover: #1ed760;
    --accent-dim: rgba(29, 185, 84, 0.15);
    --accent-warm: #E8A838;
    --danger: #e74c3c;
    --danger-hover: #ff5252;
    --border: #2a2a2a;
    --border-light: #333333;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 50%;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-reading: Georgia, 'Times New Roman', serif;
    --transition-fast: 150ms ease;
    --transition: 250ms ease;
    --transition-slow: 400ms ease;
    --player-height: 90px;
    --header-height: 64px;
    --scrollbar-thumb: #4a4a4a;
    --scrollbar-track: transparent;
}

[data-theme="light"] {
    --bg-primary: #f8f8f8;
    --bg-secondary: #ffffff;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0f0;
    --bg-input: #f0f0f0;
    --text-primary: #191414;
    --text-secondary: #535353;
    --text-muted: #878787;
    --accent: #1DB954;
    --accent-hover: #18a34a;
    --accent-dim: rgba(29, 185, 84, 0.1);
    --border: #e5e5e5;
    --border-light: #d0d0d0;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
    --scrollbar-thumb: #c0c0c0;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: var(--accent);
    color: white;
}

/* Links */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--accent-hover);
}

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

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}
.logo:hover {
    color: var(--text-primary);
}

.logo-icon {
    color: var(--accent);
}

.header-nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}
.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}
.nav-link.active {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.theme-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: block; }

/* Main Content */
.app-main {
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding-bottom: calc(var(--player-height) + 20px);
    transition: padding-bottom var(--transition);
}

.app-main.no-player {
    padding-bottom: 20px;
}

/* View containers */
.view {
    padding: 32px 24px;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

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

/* Section headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

/* Forms */
select, input[type="text"] {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color var(--transition-fast);
    outline: none;
}
select:focus, input[type="text"]:focus {
    border-color: var(--accent);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-pdf {
    background: #e74c3c22;
    color: #e74c3c;
}
.badge-epub {
    background: #3498db22;
    color: #3498db;
}
.badge-txt {
    background: #2ecc7122;
    color: #2ecc71;
}

/* Progress bar */
.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width var(--transition);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 3s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 380px;
}

.toast-success { border-left: 3px solid var(--accent); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid #3498db; }

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

/* Loading Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px;
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 40px;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 20px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 24px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ============================================
   Dashboard Styles
   ============================================ */
.dashboard-view {
    padding: 0;
    max-width: 900px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.dashboard-hero {
    text-align: center;
    padding: 48px 24px 32px;
}

.dashboard-hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dashboard-logo {
    animation: fadeIn 0.5s ease;
}

.dashboard-title {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 400px;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 0 24px;
    margin-bottom: 32px;
}

.dashboard-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
    transition: all var(--transition-fast);
}

.dashboard-stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
}

.stat-icon-accent {
    color: var(--accent);
}

.stat-icon-warm {
    color: var(--accent-warm);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.dashboard-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 0 24px;
    margin-bottom: 32px;
}

.dashboard-action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dashboard-action-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

.dashboard-action-primary {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.dashboard-action-primary .action-icon {
    color: var(--accent);
}

.action-icon {
    color: var(--text-secondary);
}

.dashboard-action-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.dashboard-action-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dashboard-recent {
    padding: 0 24px 40px;
}

.dashboard-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.dashboard-recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.dashboard-book-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.dashboard-book-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.dashboard-book-cover {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.6);
}

.dashboard-book-info {
    padding: 8px 10px;
}

.dashboard-book-title {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.dashboard-book-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.dashboard-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive - Dashboard */
@media (max-width: 768px) {
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-title {
        font-size: 1.8rem;
    }

    .dashboard-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .dashboard-hero {
        padding: 32px 16px 24px;
    }

    .dashboard-stats {
        padding: 0 16px;
    }

    .dashboard-actions {
        padding: 0 16px;
    }

    .dashboard-recent {
        padding: 0 16px 40px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 0 16px;
    }

    .logo-text {
        display: none;
    }

    .nav-link span {
        display: none;
    }

    .view {
        padding: 20px 16px;
    }

    .section-title {
        font-size: 1.4rem;
    }

    :root {
        --player-height: 120px;
    }
}

@media (max-width: 480px) {
    .header-nav {
        gap: 4px;
    }

    .nav-link {
        padding: 8px 10px;
    }
}
