/* VI: Design Tokens. Hệ thống biến tập trung quản lý màu sắc, khoảng cách, bo góc cho cả 2 theme (dark/light).
EN: Design Tokens. Central variables for color, spacing and radius, for both dark and light themes. */
:root {
    --sidebar-width: 236px;
    --header-height: 72px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 999px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    /* Pomodoro phase colors, shared by both themes */
    --mode-work: #f2715a;
    --mode-short: #2bb39a;
    --mode-long: #5b8cf0;

    --transition: 160ms ease;
}

/* VI: Theme tối (mặc định). EN: Dark theme (default). */
:root,
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1116;
    --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(109, 124, 255, 0.12), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(43, 179, 154, 0.08), transparent 60%);
    --surface: #161920;
    --surface-2: #1d2129;
    --surface-3: #252a34;
    --border: #262b35;
    --border-strong: #343a47;
    --text: #e9ebf0;
    --text-muted: #8d94a3;
    --text-faint: #5d6472;
    --accent: #7b88ff;
    --accent-strong: #6a77f5;
    --accent-soft: rgba(123, 136, 255, 0.14);
    --accent-contrast: #ffffff;
    --danger: #ef5a5a;
    --warning: #f0a92e;
    --success: #2bb39a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
    --overlay: rgba(6, 8, 12, 0.65);
}

/* VI: Theme sáng. EN: Light theme. */
[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f5f8;
    --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(79, 94, 232, 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(43, 179, 154, 0.08), transparent 60%);
    --surface: #ffffff;
    --surface-2: #f2f3f7;
    --surface-3: #e8eaf0;
    --border: #e4e6ec;
    --border-strong: #d3d7e0;
    --text: #181b22;
    --text-muted: #5c6474;
    --text-faint: #9097a5;
    --accent: #4f5ee8;
    --accent-strong: #4351d6;
    --accent-soft: rgba(79, 94, 232, 0.10);
    --accent-contrast: #ffffff;
    --danger: #d93c3c;
    --warning: #c98200;
    --success: #1f9a83;
    --shadow-sm: 0 1px 2px rgba(20, 24, 40, 0.06);
    --shadow-md: 0 8px 24px rgba(20, 24, 40, 0.08);
    --shadow-lg: 0 20px 50px rgba(20, 24, 40, 0.16);
    --overlay: rgba(20, 24, 34, 0.4);
}

/* VI: Global Reset. EN: Global reset. */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg-glow), var(--bg);
    background-attachment: fixed;
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    background: none;
    border: none;
}

a {
    color: var(--accent);
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

::selection {
    background: var(--accent-soft);
}

/* VI: App Shell. Sidebar cố định + vùng nội dung tự cuộn.
EN: App shell. Fixed sidebar + independently scrolling content. */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: var(--space-6) var(--space-4);
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-2);
    margin-bottom: var(--space-8);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent), var(--mode-long));
    color: #fff;
    font-size: 21px;
    box-shadow: 0 6px 16px var(--accent-soft);
}

.brand-name {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.nav-link i {
    font-size: 20px;
}

.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.sidebar-footer {
    margin-top: auto;
}

.sidebar-tip {
    line-height: 1.7;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12.5px;
}

kbd {
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    background: var(--surface);
    font-family: var(--font-sans);
    font-size: 11.5px;
    color: var(--text);
}

.main-content {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.header-bar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    height: var(--header-height);
    padding: 0 var(--space-8);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 5;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    min-width: 110px;
}

.view-scroll {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-8);
}

/* VI: Chỉ hiển thị view đang active, có hiệu ứng chuyển cảnh nhẹ.
EN: Only the active view is shown, with a subtle entrance. */
.app-view {
    display: none;
    max-width: 1120px;
    margin: 0 auto;
}

.app-view.active {
    display: block;
    animation: view-in 260ms ease;
}

@keyframes view-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
