/* ============================================
   JB Timing — BMW CI Design System
   ============================================ */

:root {
    --bmw-blue: #0066B1;
    --bmw-blue-light: #E8F1F8;
    --bmw-blue-hover: #004E8C;
    --bmw-blue-10: rgba(0, 102, 177, 0.08);
    --bmw-dark: #1C1C1C;
    --bmw-gray-900: #262626;
    --bmw-gray-700: #4A4A4A;
    --bmw-gray-500: #8E8E8E;
    --bmw-gray-300: #CCCCCC;
    --bmw-gray-200: #E5E5E5;
    --bmw-gray-100: #F2F2F2;
    --bmw-gray-50: #F8F9FA;
    --bmw-white: #FFFFFF;
    --bmw-success: #00884B;
    --bmw-warning: #E8A200;
    --bmw-danger: #D0021B;
    --bmw-info: #0066B1;

    --color-office: #0066B1;
    --color-mobile-full: #00884B;
    --color-mobile-partial: #5BB486;
    --color-hybrid: #E8A200;
    --color-vacation: #8B5CF6;
    --color-holiday: #EC4899;

    --sidebar-width: 240px;
    --topbar-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--bmw-gray-900);
    background: var(--bmw-gray-50);
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--bmw-blue); text-decoration: none; }
a:hover { color: var(--bmw-blue-hover); }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed; left: 0; top: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--bmw-white);
    border-right: 1px solid var(--bmw-gray-200);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--bmw-gray-200);
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--bmw-blue);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 20px;
}
.brand-text {
    font-size: 18px; font-weight: 700;
    color: var(--bmw-gray-900);
    letter-spacing: -0.3px;
}

.nav-section { flex: 1; padding: 12px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--bmw-gray-700);
    font-weight: 500; font-size: 14px;
    transition: all var(--transition);
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--bmw-gray-100); color: var(--bmw-gray-900); }
.nav-item.active {
    background: var(--bmw-blue-10);
    color: var(--bmw-blue);
}
.nav-item .material-icons-outlined { font-size: 20px; }

.nav-footer {
    padding: 12px;
    border-top: 1px solid var(--bmw-gray-200);
}
.user-info {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    color: var(--bmw-gray-500);
    font-size: 13px;
}
.nav-item.logout { color: var(--bmw-gray-500); }
.nav-item.logout:hover { color: var(--bmw-danger); background: #FEF2F2; }

/* ---- Main wrapper ---- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--bmw-white);
    border-bottom: 1px solid var(--bmw-gray-200);
    display: flex; align-items: center;
    padding: 0 32px; gap: 16px;
    position: sticky; top: 0; z-index: 50;
}
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--bmw-gray-700); }
.page-title {
    font-size: 20px; font-weight: 600;
    color: var(--bmw-gray-900);
    letter-spacing: -0.3px;
}
.top-bar-right { margin-left: auto; }
.current-date { font-size: 13px; color: var(--bmw-gray-500); font-weight: 400; }

.content { padding: 28px 32px; max-width: 1400px; }

/* ---- Cards ---- */
.card {
    background: var(--bmw-white);
    border: 1px solid var(--bmw-gray-200);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.card-title {
    font-size: 16px; font-weight: 600;
    color: var(--bmw-gray-900);
}
.card-subtitle {
    font-size: 13px; color: var(--bmw-gray-500);
    margin-top: 2px;
}

/* ---- KPI Grid ---- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--bmw-white);
    border: 1px solid var(--bmw-gray-200);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute; left: 0; top: 0;
    width: 3px; height: 100%;
}
.kpi-card.blue::before { background: var(--bmw-blue); }
.kpi-card.green::before { background: var(--bmw-success); }
.kpi-card.orange::before { background: var(--bmw-warning); }
.kpi-card.purple::before { background: #8B5CF6; }
.kpi-card.red::before { background: var(--bmw-danger); }

.kpi-label {
    font-size: 12px; font-weight: 500;
    color: var(--bmw-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.kpi-value {
    font-size: 28px; font-weight: 700;
    color: var(--bmw-gray-900);
    letter-spacing: -0.5px;
    line-height: 1;
}
.kpi-sub {
    font-size: 12px; color: var(--bmw-gray-500);
    margin-top: 6px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500;
    border: none; cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-primary {
    background: var(--bmw-blue);
    color: white;
}
.btn-primary:hover { background: var(--bmw-blue-hover); }
.btn-secondary {
    background: var(--bmw-gray-100);
    color: var(--bmw-gray-700);
    border: 1px solid var(--bmw-gray-200);
}
.btn-secondary:hover { background: var(--bmw-gray-200); }
.btn-danger { background: #FEF2F2; color: var(--bmw-danger); }
.btn-danger:hover { background: #FEE2E2; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn .material-icons-outlined { font-size: 16px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--bmw-gray-700);
    margin-bottom: 6px;
}
.form-input, .form-select {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--bmw-gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit;
    color: var(--bmw-gray-900);
    background: var(--bmw-white);
    transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--bmw-blue);
    box-shadow: 0 0 0 3px var(--bmw-blue-10);
}
.form-row {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.form-hint {
    font-size: 12px; color: var(--bmw-gray-500);
    margin-top: 4px;
}

/* ---- Tables ---- */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%; border-collapse: collapse;
    font-size: 14px;
}
thead th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600; font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bmw-gray-500);
    border-bottom: 2px solid var(--bmw-gray-200);
    white-space: nowrap;
}
tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--bmw-gray-100);
    color: var(--bmw-gray-700);
}
tbody tr:hover { background: var(--bmw-gray-50); }

/* ---- Tags / Badges ---- */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px; font-weight: 500;
    white-space: nowrap;
}
.badge-office { background: #E8F1F8; color: var(--color-office); }
.badge-mobile-full { background: #E6F7ED; color: var(--color-mobile-full); }
.badge-mobile-partial { background: #E6F7ED; color: var(--color-mobile-partial); }
.badge-hybrid { background: #FEF7E0; color: #B07D00; }
.badge-vacation { background: #F3E8FF; color: var(--color-vacation); }
.badge-holiday { background: #FDE7F0; color: var(--color-holiday); }

/* ---- Calendar ---- */
.calendar-nav {
    display: flex; align-items: center; justify-content: center;
    gap: 16px; margin-bottom: 20px;
}
.calendar-nav .month-label {
    font-size: 16px; font-weight: 600;
    min-width: 180px; text-align: center;
}
.calendar-nav button {
    background: none; border: 1px solid var(--bmw-gray-200);
    border-radius: var(--radius-sm); cursor: pointer;
    padding: 6px 10px; color: var(--bmw-gray-700);
    transition: all var(--transition);
}
.calendar-nav button:hover { background: var(--bmw-gray-100); }

.calendar-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.calendar-month-header {
    text-align: center; font-weight: 600;
    color: var(--bmw-gray-700);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--bmw-gray-200);
    margin-bottom: 8px;
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-header {
    text-align: center;
    font-size: 11px; font-weight: 600;
    color: var(--bmw-gray-500);
    padding: 4px;
    text-transform: uppercase;
}
.cal-day {
    aspect-ratio: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    position: relative;
    transition: all var(--transition);
    min-height: 38px;
}
.cal-day:hover { background: var(--bmw-gray-100); }
.cal-day.today {
    font-weight: 700;
    box-shadow: inset 0 0 0 2px var(--bmw-blue);
}
.cal-day.other-month { color: var(--bmw-gray-300); }
.cal-day.weekend { color: var(--bmw-gray-400); }
.cal-day.selected { background: var(--bmw-blue); color: white; }
.cal-day .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    position: absolute; bottom: 3px;
}
.cal-day .dots {
    display: flex; gap: 2px;
    position: absolute; bottom: 3px;
}
.cal-day .dots .dot { position: static; }

/* ---- Heatmap ---- */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 18px);
    gap: 3px;
}
.heatmap-cell {
    width: 18px; height: 18px;
    border-radius: 3px;
    background: var(--bmw-gray-100);
}
.heatmap-cell.l1 { background: #BFDBFE; }
.heatmap-cell.l2 { background: #60A5FA; }
.heatmap-cell.l3 { background: #2563EB; }
.heatmap-cell.l4 { background: #1D4ED8; }
.heatmap-cell.l5 { background: #1E3A8A; }

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bmw-white);
    border-radius: var(--radius-lg);
    width: 90%; max-width: 560px;
    max-height: 85vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 200ms ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--bmw-gray-200);
}
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--bmw-gray-500); font-size: 20px;
    padding: 4px;
}
.modal-close:hover { color: var(--bmw-gray-900); }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--bmw-gray-200);
}

/* ---- Result Box ---- */
.result-box {
    background: var(--bmw-gray-50);
    border: 1px solid var(--bmw-gray-200);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 16px;
}
.result-row {
    display: flex; justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}
.result-row.total {
    border-top: 2px solid var(--bmw-gray-300);
    margin-top: 8px; padding-top: 10px;
    font-weight: 600;
}
.result-label { color: var(--bmw-gray-500); }
.result-value { font-weight: 600; color: var(--bmw-gray-900); }

/* ---- Charts Area ---- */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}
.chart-toggle {
    display: flex; gap: 4px;
    background: var(--bmw-gray-100);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.chart-toggle button {
    padding: 6px 14px;
    border: none; border-radius: 4px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; background: transparent;
    color: var(--bmw-gray-500);
    transition: all var(--transition);
    font-family: inherit;
}
.chart-toggle button.active {
    background: var(--bmw-white);
    color: var(--bmw-gray-900);
    box-shadow: var(--shadow-sm);
}

/* ---- Tabs ---- */
.tabs {
    display: flex; gap: 0;
    border-bottom: 2px solid var(--bmw-gray-200);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 20px;
    font-size: 14px; font-weight: 500;
    color: var(--bmw-gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
}
.tab:hover { color: var(--bmw-gray-700); }
.tab.active {
    color: var(--bmw-blue);
    border-bottom-color: var(--bmw-blue);
}

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 16px;
}
.alert-warning { background: #FEF7E0; color: #92660A; border: 1px solid #FDE68A; }
.alert-danger { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #E6F7ED; color: #065F46; border: 1px solid #A7F3D0; }

/* ---- Login Page ---- */
.login-wrapper {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #F8F9FA 0%, #E8F1F8 100%);
}
.login-card {
    background: var(--bmw-white);
    border-radius: var(--radius-lg);
    padding: 48px;
    width: 100%; max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-brand {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 36px;
}
.login-brand .brand-icon { width: 44px; height: 44px; font-size: 24px; }
.login-brand .brand-text { font-size: 22px; }
.login-error {
    background: #FEF2F2; color: var(--bmw-danger);
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 16px;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .calendar-months { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .menu-toggle { display: block; }
    .content { padding: 20px 16px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bmw-gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bmw-gray-500); }

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeIn 300ms ease-out; }

/* ---- Utility ---- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--bmw-gray-500); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---- Entry type selector ---- */
.type-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}
.type-option {
    padding: 12px;
    border: 2px solid var(--bmw-gray-200);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px; font-weight: 500;
}
.type-option:hover { border-color: var(--bmw-gray-300); }
.type-option.selected { border-color: var(--bmw-blue); background: var(--bmw-blue-10); color: var(--bmw-blue); }
.type-option .material-icons-outlined { display: block; font-size: 24px; margin-bottom: 4px; }

/* ---- Settings sections ---- */
.settings-section { margin-bottom: 32px; }
.settings-section h3 {
    font-size: 15px; font-weight: 600;
    color: var(--bmw-gray-900);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bmw-gray-200);
}
.rule-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px;
    background: var(--bmw-gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}
.rule-row .form-input { width: auto; max-width: 100px; }

/* ---- Day detail panel ---- */
.day-detail {
    background: var(--bmw-gray-50);
    border: 1px solid var(--bmw-gray-200);
    border-radius: var(--radius-md);
    padding: 20px;
}
.day-detail-header {
    font-size: 15px; font-weight: 600;
    margin-bottom: 16px;
    color: var(--bmw-gray-900);
}
.entry-card {
    background: var(--bmw-white);
    border: 1px solid var(--bmw-gray-200);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
}
.entry-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.entry-actions { display: flex; gap: 4px; }
.entry-actions button {
    background: none; border: none; cursor: pointer;
    color: var(--bmw-gray-500); padding: 2px;
    transition: color var(--transition);
}
.entry-actions button:hover { color: var(--bmw-gray-900); }
.entry-actions button.delete:hover { color: var(--bmw-danger); }

/* ---- Legend ---- */
.legend {
    display: flex; flex-wrap: wrap; gap: 16px;
    margin-bottom: 16px;
}
.legend-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--bmw-gray-500);
}
.legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
}

/* ---- Toggle Switch ---- */
.toggle-wrapper { display: flex; align-items: center; gap: 10px; }
.toggle {
    position: relative;
    width: 44px; height: 24px;
    background: var(--bmw-gray-300);
    border-radius: 12px;
    cursor: pointer;
    transition: background var(--transition);
}
.toggle.active { background: var(--bmw-blue); }
.toggle::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 20px; height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition);
}
.toggle.active::after { transform: translateX(20px); }

/* ---- Loading ---- */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--bmw-gray-200);
    border-top-color: var(--bmw-blue);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast notification ---- */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--bmw-gray-900);
    color: white; padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px; z-index: 300;
    animation: toastIn 300ms ease-out;
    box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--bmw-success); }
.toast.error { background: var(--bmw-danger); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
