/* --- DESIGN SYSTEM --- */
:root {
    --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Theme Colors */
    --bg-gradient-dark: radial-gradient(circle at 10% 20%, rgba(129, 140, 248, 0.1), transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(192, 132, 252, 0.1), transparent 50%),
                      #020617;
    --bg-dark: #020617;
    --card-bg-dark: #0f172a;
    --card-border-dark: #1e293b;
    --text-primary-dark: #f8fafc;
    --text-secondary-dark: #94a3b8;
    --text-tertiary-dark: #475569;
    --input-bg-dark: #020617;

    --bg-gradient-light: #f1f5f9;
    --bg-light: #f1f5f9;
    --card-bg-light: #ffffff;
    --card-border-light: #e2e8f0;
    --text-primary-light: #0f172a;
    --text-secondary-light: #475569;
    --text-tertiary-light: #cbd5e1;
    --input-bg-light: #f8fafc;

    --accent: #818cf8;
    --accent-glow: 0 0 20px -5px #818cf8;
    --focus-ring-color: rgba(129, 140, 248, 0.4);

    /* Timeline Semantic Colors */
    --time-bg: transparent;
    --time-text: var(--text-tertiary);
    --time-border: var(--card-border);

    --work-bg: rgba(34, 197, 94, 0.1);
    --work-text: #a7f3d0;
    --work-border: #15803d;

    --overlap-bg: rgba(250, 204, 21, 0.1);
    --overlap-text: #fde68a;
    --overlap-border: #ca8a04;

    --golden-bg: rgba(252, 211, 77, 0.25);
    --golden-text: #fef08a;
    --golden-border: #f59e0b;

    --marker: #f472b6;
    --marker-glow: 0 0 15px -3px #f472b6;

    /* Shadows */
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    --shadow-lg-light: 0 10px 15px -3px rgba(0,0,0,0.07), 0 4px 6px -2px rgba(0,0,0,0.05);

    /* Transitions */
    --transition-fast: all 0.2s ease-in-out;
}

/* --- THEME SETUP --- */
.dark {
    --bg-gradient: var(--bg-gradient-dark);
    --bg: var(--bg-dark);
    --card-bg: var(--card-bg-dark);
    --card-border: var(--card-border-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --text-tertiary: var(--text-tertiary-dark);
    --input-bg: var(--input-bg-dark);
    --shadow: var(--shadow-lg);
}

.light {
    --bg-gradient: var(--bg-gradient-light);
    --bg: var(--bg-light);
    --card-bg: var(--card-bg-light);
    --card-border: var(--card-border-light);
    --text-primary: var(--text-primary-light);
    --text-secondary: var(--text-secondary-light);
    --text-tertiary: var(--text-tertiary-light);
    --input-bg: var(--input-bg-light);
    --shadow: var(--shadow-lg-light);

    /* Adjust semantic colors for light theme */
    --work-bg: #dcfce7;
    --work-text: #14532d;
    --work-border: #4ade80;
    --overlap-bg: #fef9c3;
    --overlap-text: #713f12;
    --overlap-border: #facc15;
    --golden-bg: #fef08a;
    --golden-text: #854d0e;
    --golden-border: #f59e0b;
}

/* --- GLOBAL STYLES --- */
body { margin: 0; font-family: var(--font-sans); background: var(--bg-gradient); color: var(--text-primary); font-size: 14px; line-height: 1.6; transition: background 0.3s; }
.container { max-width: 1400px; margin: 0 auto; padding: 16px; }
#main-card { padding: 24px; border: 1px solid var(--card-border); background: var(--card-bg); border-radius: 24px; box-shadow: var(--shadow); }

/* --- HEADER --- */
.header-main { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.header-content h1 { font-size: 24px; font-weight: 700; margin: 0; }
.header-content .sub { font-size: 14px; color: var(--text-secondary); margin: 4px 0 0; }
.theme-toggle { background: none; border: none; cursor: pointer; padding: 8px; color: var(--text-secondary); border-radius: 99px; line-height: 1; transition: var(--transition-fast); }
.theme-toggle:hover { color: var(--accent); background-color: var(--card-border); }

/* --- CONTROLS GRID --- */
.controls-grid { display: grid; grid-template-columns: repeat(2, 1fr) auto auto; gap: 16px; align-items: flex-end; margin-bottom: 24px; }
@media (max-width: 1200px) { .controls-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { .controls-grid { grid-template-columns: 1fr; } }

.field label { display: block; font-weight: 600; margin-bottom: 8px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group i { position: absolute; left: 14px; z-index: 1; color: var(--text-tertiary); width: 16px; height: 16px; }

.search, select, input[type="datetime-local"] { font-family: var(--font-sans); width: 100%; padding: 12px 14px 12px 42px; border-radius: 12px; border: 1px solid var(--card-border); background: var(--input-bg); color: var(--text-primary); outline: none; transition: var(--transition-fast); }
select { appearance: none; }
select:not([multiple]) { padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.search:focus, select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring-color); }
.input-group.add-tz-group .search { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group.add-tz-group button { border-top-left-radius: 0; border-bottom-left-radius: 0; height: 100%; }

.action-buttons { display: flex; gap: 12px; align-items: center; height: 100%; }
.hint { font-size: 13px; color: var(--accent); margin-left: 8px; }

button { font-family: var(--font-sans); font-weight: 600; padding: 10px 16px; border-radius: 12px; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background-color: var(--accent); color: white; transition: var(--transition-fast); }
button:hover { box-shadow: var(--accent-glow); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.subtle { background-color: transparent; color: var(--text-secondary); border: 1px solid var(--card-border); }
button.subtle:hover { background-color: var(--card-border); color: var(--text-primary); box-shadow: none; }

/* --- TIMELINE LEGEND --- */
.timeline-legend { display: flex; justify-content: flex-end; align-items: center; gap: 20px; margin-bottom: 20px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--card-border); }
.legend-swatch.is-work { background-color: var(--work-bg); border-color: var(--work-border); }
.legend-swatch.is-overlap { background-color: var(--overlap-bg); border-color: var(--overlap-border); }
.legend-swatch.is-golden { background-color: var(--golden-bg); border-color: var(--golden-border); }


/* --- TIMELINE --- */
.timeline-wrapper { overflow-x: auto; }
.timeline-header { display: flex; padding-bottom: 4px; }
.timeline-info-header { flex: 0 0 220px; padding-right: 20px; }
.timeline-labels { display: grid; grid-template-columns: repeat(24, 1fr); flex-grow: 1; }
.hour-label { text-align: center; font-size: 11px; color: var(--text-secondary); }
#timeline-container { position: relative; }

.timeline-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--card-border); }
.timeline-row:last-child { border-bottom: none; }

.timeline-info { flex: 0 0 220px; padding: 14px 20px 14px 0; display: flex; flex-direction: column; justify-content: center; }
.tz-name { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.tz-name .base-tag { font-size: 10px; font-weight: 700; background-color: var(--accent); color: white; padding: 2px 6px; border-radius: 6px; }
.tz-current-time { font-size: 12px; color: var(--accent); font-weight: 500; }
.tz-meta { font-size: 12px; color: var(--text-secondary); }
.remove-tz-btn { margin-left: auto; background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 4px; border-radius: 99px; line-height: 1; }
.remove-tz-btn:hover { background-color: var(--card-border); color: #f43f5e; }

.timeline-track { flex-grow: 1; display: grid; grid-template-columns: repeat(24, 1fr); position: relative; }

.hour-block {
    position: relative;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 0;
    border-right: 1px solid var(--time-border);
    background-color: var(--time-bg);
    color: var(--time-text);
    transition: var(--transition-fast);
}
.hour-block:last-child { border-right: none; }

/* States */
.hour-block.is-work { background-color: var(--work-bg); color: var(--work-text); border-color: var(--work-border); }
.hour-block.is-overlap { background-color: var(--overlap-bg); color: var(--overlap-text); border-color: var(--overlap-border); }
.hour-block.is-golden { background-color: var(--golden-bg); color: var(--golden-text); border-color: var(--golden-border); font-weight: 700; }

.current-time-marker {
    position: absolute;
    top: -12px;
    bottom: 0;
    width: 3px;
    background-color: var(--marker);
    box-shadow: var(--marker-glow);
    border-radius: 3px;
    z-index: 10;
    pointer-events: none;
    margin-left: 220px; /* Aligns with info width */
}

/* --- FOOTER --- */
.footer { text-align: center; padding: 40px 0 20px; color: var(--text-secondary); font-size: 12px; }
.footer nav { margin-top: 8px; display: flex; gap: 16px; justify-content: center; }
.footer nav a { color: var(--text-secondary); text-decoration: none; }
.footer nav a:hover { color: var(--text-primary); text-decoration: underline; }
