/* Theme & Variables */
:root {
    --bg-base: #0F172A;
    /* Slate 900 */
    --bg-panel: #1E293B;
    /* Slate 800 */
    --bg-hover: #334155;

    --primary: #6366F1;
    /* Indigo 500 */
    --primary-hover: #4F46E5;
    --primary-dim: rgba(99, 102, 241, 0.15);

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;

    --border: #334155;

    --success: #10B981;
    --error: #EF4444;

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --font-ui: 'Inter', system-ui, sans-serif;

    /* Keyboard Colors */
    --key-bg: #1E293B;
    --key-border: #0F172A;
    --key-shadow: #020617;
    --key-text: #CBD5E1;

    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

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

.mt-4 {
    margin-top: 1.5rem;
}

.text-primary {
    color: var(--primary);
    font-weight: 600;
}

.text-muted {
    color: var(--text-muted);
}

.text-error {
    color: var(--error);
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: #FFF;
    box-shadow: 0 4px 12px var(--primary-dim);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Layout */
.app-layout {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
}

.logo-box {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #A5B4FC);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    box-shadow: 0 0 15px var(--primary-dim);
}

.brand h1 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.nav-menu {
    flex: 1;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary-dim);
    color: var(--primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.streak-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.streak-emoji {
    font-size: 1.5rem;
}

.streak-num {
    font-weight: 600;
    font-size: 1rem;
    color: #FFF;
}

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

/* Main Content Area */
.main-content {
    flex: 1;
    overflow: auto;
    position: relative;
}

.view {
    display: none;
    padding: 3rem;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    flex-direction: column;
}

.view.active {
    display: flex;
}

.view-header {
    margin-bottom: 2rem;
}

.view-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #FFF;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Dashboard View */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-val {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.action-banner {
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    background: linear-gradient(to right, rgba(30, 41, 59, 0.8), rgba(99, 102, 241, 0.1));
}

.banner-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.banner-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Library Grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.lib-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.lib-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.lib-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.lib-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    flex: 1;
}

.lib-meta {
    font-size: 0.8rem;
    font-family: monospace;
    color: var(--primary);
    background: var(--primary-dim);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Settings View */
.settings-card {
    padding: 2rem;
    max-width: 600px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-input {
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: #FFF;
    padding: 0.5rem;
    border-radius: 4px;
    width: 80px;
    text-align: right;
}

/* Trainer View */
.trainer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 2rem;
}

.session-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 60%;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

#session-count {
    font-family: monospace;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.trainer-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.prompt-card {
    padding: 3rem;
    text-align: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 3rem;
    position: relative;
}

.prompt-app {
    font-size: 0.9rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.prompt-action {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.pressed-keys-display {
    font-family: monospace;
    font-size: 1.5rem;
    min-height: 3rem;
    margin-bottom: 1rem;
    color: var(--accent);
    font-weight: 500;
}

.placeholder-text {
    color: var(--text-muted);
    opacity: 0.5;
    font-size: 1.2rem;
}

.feedback-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 1.1rem;
    animation: bounceIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-banner.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.feedback-banner.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Visual Keyboard */
.keyboard-visualizer {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: 900px;
    width: 100%;
    margin: 0 auto 2rem;
}

.kb-row {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.k-key {
    background: var(--key-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 3px solid var(--key-border);
    border-radius: 6px;
    color: var(--key-text);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    width: 50px;
    flex-shrink: 0;
    transition: all 0.1s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    user-select: none;
}

.k-key.active {
    background: var(--primary);
    color: #FFF;
    border-bottom-width: 1px;
    transform: translateY(2px);
    box-shadow: 0 2px 3px var(--key-border), 0 0 15px var(--primary-dim);
}

.k-key.error {
    background: var(--error);
    color: #FFF;
    border-bottom-width: 1px;
    transform: translateY(2px);
    border-top-color: rgba(255, 255, 255, 0.3);
}

/* Key Sizes */
.k-small {
    height: 35px;
    width: 42px;
    font-size: 0.7rem;
}

.k-w15 {
    width: 75px;
    font-size: 0.75rem;
}

.k-w17 {
    width: 85px;
    font-size: 0.75rem;
}

.k-w22 {
    width: 110px;
    font-size: 0.75rem;
}

.k-w27 {
    width: 135px;
    font-size: 0.75rem;
}

.k-w12 {
    width: 60px;
    font-size: 0.75rem;
}

.k-space {
    width: 250px;
}

.k-spacer {
    width: 25px;
}

/* Arrows */
.k-action-group {
    display: flex;
    gap: 0.4rem;
    align-items: flex-end;
}

.k-col {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.k-nav {
    height: 23px;
    width: 40px;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 900px) {
    .keyboard-visualizer {
        display: none;
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}