/* ============================================
   Güncel Takvim — Google Calendar Style
   Light / Dark Mode
   ============================================ */

/* --- Theme Variables --- */
:root,
[data-theme="light"] {
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-hover: #f1f3f4;
    --bg-active: #e8eaed;
    --surface: #ffffff;
    --border: #dadce0;
    --border-light: #e8eaed;

    --text: #3c4043;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --text-on-primary: #ffffff;

    --primary: #1a73e8;
    --primary-hover: #1765cc;
    --primary-light: #d2e3fc;
    --primary-surface: rgba(26, 115, 232, 0.08);

    --today-bg: #1a73e8;
    --today-text: #ffffff;

    --holiday: #d50000;
    --holiday-bg: rgba(213, 0, 0, 0.08);
    --holiday-chip: #d50000;
    --holiday-chip-text: #ffffff;

    --weekend: #70757a;
    --sidebar-width: 280px;

    --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    --shadow-md: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
    --shadow-lg: 0 1px 3px 0 rgba(60,64,67,0.3), 0 8px 16px 6px rgba(60,64,67,0.15);

    --radius: 8px;
    --radius-sm: 4px;
    --radius-full: 50%;
    --transition: 0.2s ease;
    --font: 'Inter', 'Google Sans', 'Roboto', -apple-system, sans-serif;
}

/* ============================================
   DARK THEME — Radix UI Inspired
   Indigo-tinted grays, layered surfaces, crisp borders
   ============================================ */
[data-theme="dark"] {
    /* Step 1-2: Page backgrounds (indigo-tinted, never pure black) */
    --bg: #111113;
    --bg-secondary: #18191b;
    --bg-hover: rgba(200, 210, 255, 0.055);
    --bg-active: rgba(200, 210, 255, 0.1);
    /* Step 2-3: Elevated surface */
    --surface: #1a1b1e;
    /* Step 6: Borders — crisp, visible, tinted */
    --border: rgba(180, 190, 220, 0.12);
    --border-light: rgba(180, 190, 220, 0.07);

    /* Step 11-12: Text hierarchy */
    --text: #edeef0;
    --text-secondary: #b0b4ba;
    --text-muted: #6e7280;
    --text-on-primary: #fff;

    /* Accent — Indigo (Radix indigo step 9-10) */
    --primary: #6e7cf2;
    --primary-hover: #8b97f6;
    --primary-light: rgba(110, 124, 242, 0.15);
    --primary-surface: rgba(110, 124, 242, 0.06);

    --today-bg: #6e7cf2;
    --today-text: #fff;

    /* Holiday — Tomato (Radix tomato step 9-10) */
    --holiday: #e5484d;
    --holiday-bg: rgba(229, 72, 77, 0.12);
    --holiday-chip: #e5484d;
    --holiday-chip-text: #fff;

    --weekend: #7e818a;

    /* Shadows — subtle, no glow, just depth */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.45), inset 0 0 0 0.5px rgba(180,190,220,0.06);
    --shadow-md: 0 3px 8px rgba(0,0,0,0.5), inset 0 0 0 0.5px rgba(180,190,220,0.06);
    --shadow-lg: 0 8px 20px rgba(0,0,0,0.55), inset 0 0 0 0.5px rgba(180,190,220,0.06);
}

/* ============================================
   DARK — Component Overrides
   ============================================ */

/* Top bar — elevated layer 2 */
[data-theme="dark"] .topbar {
    background: #18191c;
    border-bottom: 1px solid rgba(180, 190, 220, 0.1);
    box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

/* Sidebar — layer 1, slightly different tint */
[data-theme="dark"] .sidebar {
    background: #141517;
    border-right: 1px solid rgba(180, 190, 220, 0.08);
}

/* Today button — accent outline */
[data-theme="dark"] .today-btn {
    border-color: rgba(110, 124, 242, 0.3);
    color: var(--primary);
    background: transparent;
}
[data-theme="dark"] .today-btn:hover {
    background: rgba(110, 124, 242, 0.1);
    border-color: rgba(110, 124, 242, 0.5);
    box-shadow: none;
}

/* Location pill — soft accent surface */
[data-theme="dark"] .topbar-location {
    background: rgba(110, 124, 242, 0.07);
    border: 1px solid rgba(110, 124, 242, 0.12);
    color: #b0b4ba;
}

/* Navigation buttons */
[data-theme="dark"] .nav-btn:hover,
[data-theme="dark"] .menu-btn:hover,
[data-theme="dark"] .mini-nav-btn:hover {
    background: rgba(200, 210, 255, 0.08);
}

/* Calendar weekday header row */
[data-theme="dark"] .calendar-weekdays {
    background: #16171a;
    border-bottom: 1px solid rgba(180, 190, 220, 0.1);
}

/* Day cells — crisp borders */
[data-theme="dark"] .day-cell {
    border-color: rgba(180, 190, 220, 0.06);
}
[data-theme="dark"] .day-cell:hover {
    background: rgba(200, 210, 255, 0.04);
}
[data-theme="dark"] .day-cell.other-month {
    background: rgba(0, 0, 10, 0.25);
}

/* Today number — solid accent, subtle shadow */
[data-theme="dark"] .day-cell.today .day-number {
    box-shadow: 0 0 0 2px rgba(110, 124, 242, 0.2);
}

/* Holiday chips — Radix "soft" variant */
[data-theme="dark"] .holiday-chip {
    background: rgba(229, 72, 77, 0.12);
    color: #ff6369;
    border: none;
    border-left: 2px solid var(--holiday);
}
[data-theme="dark"] .holiday-chip:hover {
    background: rgba(229, 72, 77, 0.22);
    color: #ff8183;
    box-shadow: none;
}

/* Holiday dots in sidebar */
[data-theme="dark"] .holiday-dot {
    box-shadow: none;
    opacity: 0.9;
}

/* Holiday count badge */
[data-theme="dark"] .holiday-badge {
    background: rgba(229, 72, 77, 0.12);
    color: #ff6369;
    border: none;
}

/* Mini calendar today */
[data-theme="dark"] .mini-day.today {
    box-shadow: none;
    font-weight: 700;
}

/* Theme toggle — golden crescent */
[data-theme="dark"] .theme-toggle {
    color: #f5d565;
}
[data-theme="dark"] .theme-toggle:hover {
    background: rgba(245, 213, 101, 0.08);
}

/* Logo glow */
[data-theme="dark"] .logo svg {
    filter: drop-shadow(0 0 4px rgba(110, 124, 242, 0.25));
}
[data-theme="dark"] .logo span {
    color: #b0b4ba;
}

/* Clock */
[data-theme="dark"] .clock-time {
    color: var(--text);
}

/* Sidebar holidays — hover state */
[data-theme="dark"] .holiday-item:hover {
    background: rgba(200, 210, 255, 0.05);
}

/* Mobile sidebar overlay */
[data-theme="dark"] .sidebar.mobile-open {
    background: #141517;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.65);
}

/* Scrollbar in dark mode */
[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb,
[data-theme="dark"] .sidebar-holidays-list::-webkit-scrollbar-thumb {
    background: rgba(180, 190, 220, 0.12);
}

/* Month title */
[data-theme="dark"] .month-title {
    color: #edeef0;
}

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    transition: background var(--transition), color var(--transition);
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
}

/* --- App Layout --- */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   TOP BAR
   ============================================ */
.topbar {
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    gap: 8px;
    z-index: 10;
    transition: background var(--transition), border-color var(--transition);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.menu-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background var(--transition);
}

.menu-btn:hover {
    background: var(--bg-hover);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
}

.logo svg {
    color: var(--primary);
}

.topbar-center {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.today-btn {
    height: 36px;
    padding: 0 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    background: var(--surface);
    transition: background var(--transition), box-shadow var(--transition);
}

.today-btn:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-sm);
}

.nav-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background var(--transition);
}

.nav-btn:hover {
    background: var(--bg-hover);
}

.month-title {
    font-size: 22px;
    font-weight: 400;
    color: var(--text);
    margin-left: 4px;
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

/* Clock */
.topbar-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.3;
}

.clock-time {
    font-size: 16px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.clock-date {
    font-size: 11px;
    color: var(--text-muted);
}

/* Location */
.topbar-location {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--bg-hover);
    font-size: 13px;
    color: var(--text-secondary);
    transition: background var(--transition);
    white-space: nowrap;
}

.topbar-location svg {
    color: var(--primary);
    flex-shrink: 0;
}

/* Language Dropdown */
.lang-dropdown {
    position: relative;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 20px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
    border: 1px solid transparent;
}

.lang-toggle svg:first-child {
    color: var(--primary);
    flex-shrink: 0;
}

.lang-arrow {
    opacity: 0.5;
    transition: transform var(--transition);
}

.lang-dropdown.open .lang-arrow {
    transform: rotate(180deg);
}

.lang-toggle:hover {
    background: var(--bg-active);
}

.lang-current {
    min-width: 18px;
    text-align: center;
}

/* Dropdown menu */
.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.lang-dropdown.open .lang-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
}

.lang-option:hover {
    background: var(--bg-hover);
}

.lang-option.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.lang-flag {
    font-size: 16px;
    line-height: 1;
}

/* Dark mode overrides */
[data-theme="dark"] .lang-toggle {
    background: rgba(110, 124, 242, 0.07);
    border-color: rgba(110, 124, 242, 0.12);
}

[data-theme="dark"] .lang-toggle:hover {
    background: rgba(110, 124, 242, 0.14);
}

[data-theme="dark"] .lang-menu {
    background: #1e1f23;
    border-color: rgba(180, 190, 220, 0.1);
}

[data-theme="dark"] .lang-option:hover {
    background: rgba(200, 210, 255, 0.06);
}

[data-theme="dark"] .lang-option.active {
    background: rgba(110, 124, 242, 0.12);
    color: #8b97f6;
}

/* Theme Toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.theme-toggle:hover {
    background: var(--bg-hover);
}

[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ============================================
   CONTENT LAYOUT
   ============================================ */
.content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border);
    background: var(--surface);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: background var(--transition), border-color var(--transition), width var(--transition), padding var(--transition), opacity var(--transition);
}

.sidebar.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    border-right: none;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* --- Mini Calendar --- */
.mini-calendar {
    user-select: none;
}

.mini-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 0 4px;
}

.mini-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.mini-nav {
    display: flex;
    gap: 2px;
}

.mini-nav-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background var(--transition);
}

.mini-nav-btn:hover {
    background: var(--bg-hover);
}

.mini-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.mini-weekday {
    text-align: center;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 0;
    text-transform: uppercase;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.mini-day {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition);
    margin: 0 auto;
    color: var(--text);
    position: relative;
}

.mini-day:hover:not(.other) {
    background: var(--bg-hover);
}

.mini-day.other {
    color: var(--text-muted);
    opacity: 0.5;
    cursor: default;
}

.mini-day.today {
    background: var(--today-bg);
    color: var(--today-text);
    font-weight: 700;
}

.mini-day.today:hover {
    background: var(--primary-hover);
}

.mini-day.selected {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.mini-day.holiday::after {
    content: '';
    position: absolute;
    bottom: 3px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--holiday);
}

.mini-day.today.holiday::after {
    background: var(--today-text);
}

/* --- Sidebar Holidays --- */
.sidebar-holidays {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-holidays-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    margin-bottom: 4px;
}

.sidebar-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.holiday-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--holiday-bg);
    color: var(--holiday);
}

.sidebar-holidays-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 2px;
}

.sidebar-holidays-list::-webkit-scrollbar {
    width: 3px;
}
.sidebar-holidays-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.holiday-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 2px;
}

.holiday-item:hover {
    background: var(--bg-hover);
}

.holiday-item.past {
    opacity: 0.45;
}

.holiday-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--holiday);
    flex-shrink: 0;
}

.holiday-info {
    flex: 1;
    min-width: 0;
}

.holiday-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.holiday-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.holidays-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.holidays-empty {
    padding: 24px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   MAIN CALENDAR
   ============================================ */
.calendar {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    transition: background var(--transition), border-color var(--transition);
}

.weekday-header {
    text-align: center;
    padding: 8px 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.weekday-header.weekend {
    color: var(--weekend);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(auto-fill, 1fr);
    flex: 1;
}

/* --- Day Cell --- */
.day-cell {
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    padding: 4px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    transition: background var(--transition);
    cursor: default;
}

.day-cell:nth-child(7n) {
    border-right: none;
}

.day-cell:hover {
    background: var(--bg-hover);
}

.day-cell.other-month {
    background: var(--bg-secondary);
}

.day-cell.other-month .day-number {
    color: var(--text-muted);
    opacity: 0.5;
}

.day-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    margin: 2px auto 4px auto;
    color: var(--text);
    transition: background var(--transition), color var(--transition);
}

.day-cell.weekend .day-number {
    color: var(--weekend);
}

.day-cell.today .day-number {
    background: var(--today-bg);
    color: var(--today-text);
    font-weight: 700;
}

/* Holiday chip inside day cell */
.holiday-chip {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--holiday-bg);
    color: var(--holiday);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
    cursor: default;
    transition: background var(--transition);
    line-height: 1.5;
}

.holiday-chip:hover {
    background: var(--holiday);
    color: var(--holiday-chip-text);
}

/* Observance chip — amber/orange variant */
.holiday-chip.observance {
    background: rgba(245, 166, 35, 0.1);
    color: #b57d14;
    border-left: 2px dashed #d4940f;
}

.holiday-chip.observance:hover {
    background: rgba(245, 166, 35, 0.2);
    color: #a06b0f;
}

/* Observance dot in sidebar */
.holiday-dot.observance {
    background: #d4940f;
}

/* Dark mode observance */
[data-theme="dark"] .holiday-chip.observance {
    background: rgba(245, 166, 35, 0.1);
    color: #f0b94d;
    border-left: 2px dashed #d4940f;
}

[data-theme="dark"] .holiday-chip.observance:hover {
    background: rgba(245, 166, 35, 0.2);
    color: #f5c966;
}

[data-theme="dark"] .holiday-dot.observance {
    background: #d4940f;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 960px) {
    .sidebar {
        width: 0;
        padding: 0;
        overflow: hidden;
        opacity: 0;
        border-right: none;
    }

    .sidebar.mobile-open {
        width: var(--sidebar-width);
        padding: 16px;
        opacity: 1;
        border-right: 1px solid var(--border);
        position: absolute;
        top: 64px;
        left: 0;
        bottom: 0;
        z-index: 20;
        box-shadow: var(--shadow-lg);
    }

    .topbar-left {
        min-width: auto;
    }

    .logo span {
        display: none;
    }

    .topbar-clock {
        display: none;
    }

    .month-title {
        font-size: 18px;
    }

    .day-cell {
        min-height: 60px;
    }
}

@media (max-width: 600px) {
    .topbar {
        height: 56px;
        padding: 0 8px;
    }

    .topbar-location {
        display: none;
    }

    .month-title {
        font-size: 16px;
    }

    .today-btn {
        padding: 0 12px;
        height: 32px;
        font-size: 13px;
    }

    .day-cell {
        min-height: 48px;
        padding: 2px;
    }

    .day-number {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }

    .holiday-chip {
        font-size: 9px;
        padding: 1px 4px;
    }
}
