/* ===== RESET & VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #e0e7ff;
  --success:       #10b981;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --sidebar-bg:    #1e1b4b;
  --sidebar-text:  #c7d2fe;
  --sidebar-hover: rgba(255,255,255,0.08);
  --text:          #111827;
  --text-muted:    #6b7280;
  --border:        #e2e8f0;
  --shadow:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:     0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --radius:        10px;
  --radius-sm:     6px;
  --font:          'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w:     220px;
}

[data-theme="dark"] {
  --bg:           #0f172a;
  --surface:      #1e293b;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --border:       #334155;
  --shadow:       0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:    0 4px 6px rgba(0,0,0,0.3);
  --primary-light:#312e81;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

/* ===== AUTH ===== */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4f46e5 100%);
  padding: 1rem;
}

#auth-screen[hidden] { display: none; }

.auth-box {
  background: #ffffff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

[data-theme="dark"] .auth-box { background: #1e293b; }

.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo span { font-size: 2.5rem; }
.auth-logo h1 { font-size: 1.6rem; font-weight: 800; color: #4f46e5; margin-top: .5rem; }
.auth-logo p  { color: #6b7280; font-size: .875rem; margin-top: .2rem; }

.auth-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid #e2e8f0;
}
.auth-tab {
  flex: 1;
  padding: .7rem;
  text-align: center;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  background: #f8fafc;
  color: #6b7280;
  border: none;
  transition: .2s;
}
[data-theme="dark"] .auth-tab { background: #0f172a; color: #94a3b8; }
.auth-tab.active { background: #4f46e5; color: #fff; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
[data-theme="dark"] .form-group label { color: #94a3b8; }

input, select, textarea {
  width: 100%;
  padding: .7rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: var(--font);
  background: #ffffff;
  color: #111827;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #0f172a;
  color: #f1f5f9;
  border-color: #334155;
}

input:focus, select:focus, textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

input[type="color"] { height: 38px; padding: .25rem .5rem; cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-ghost   { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm   { padding: .4rem .85rem; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== APP LAYOUT ===== */
#app-screen { display: flex; height: 100vh; overflow: hidden; }
#app-screen[hidden] { display: none; }

/* SIDEBAR */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform .3s;
}
.sidebar-header {
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo  { font-size: 1.3rem; }
.sidebar-title { color: #fff; font-weight: 700; font-size: 1rem; }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  cursor: pointer;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover  { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--primary); }
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; flex-shrink: 0; }
.sidebar-footer { padding: .75rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-info {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .875rem; flex-shrink: 0;
}
.user-name  { color: #fff; font-size: .8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { color: var(--sidebar-text); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* MAIN */
#main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* TIMER BAR */
#timer-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
#timer-description {
  flex: 1; min-width: 180px;
  border: none; background: transparent;
  font-size: 1rem; padding: .4rem .5rem;
}
#timer-description:focus { box-shadow: none; border-bottom: 2px solid var(--primary); border-radius: 0; outline: none; }
.timer-project-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .85rem;
  border: 1.5px dashed var(--border); border-radius: 20px;
  background: none; color: var(--text-muted); font-size: .8rem; cursor: pointer; transition: .2s; white-space: nowrap;
}
.timer-project-btn:hover { border-color: var(--primary); color: var(--primary); }
.timer-project-btn .dot { width: 8px; height: 8px; border-radius: 50%; }
.timer-tags-btn {
  padding: .5rem .85rem;
  border: 1.5px dashed var(--border); border-radius: 20px;
  background: none; color: var(--text-muted); font-size: .8rem; cursor: pointer; transition: .2s;
}
.timer-tags-btn:hover { border-color: var(--primary); color: var(--primary); }
#timer-display { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); min-width: 90px; text-align: right; }
#btn-timer-toggle {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 1.1rem; cursor: pointer;
  flex-shrink: 0; transition: .2s; display: flex; align-items: center; justify-content: center;
}
#btn-timer-toggle:hover { background: var(--primary-dark); transform: scale(1.05); }
#btn-timer-toggle.running { background: var(--danger); }

/* CONTENT */
#content-area { flex: 1; overflow-y: auto; padding: 1.5rem; background: var(--bg); }
.view { display: none; }
.view.active { display: block; }
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.view-title { font-size: 1.25rem; font-weight: 700; }

/* ===== ENTRIES ===== */
.day-group { margin-bottom: 1.5rem; }
.day-header { display: flex; align-items: center; justify-content: space-between; padding: .4rem .1rem; margin-bottom: .5rem; border-bottom: 2px solid var(--border); }
.day-label { font-weight: 700; font-size: .9rem; }
.day-total { font-weight: 700; color: var(--text-muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.entry-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: .85rem 1rem; margin-bottom: .4rem;
  display: flex; align-items: center; gap: .75rem;
  box-shadow: var(--shadow); transition: box-shadow .15s;
}
.entry-card:hover { box-shadow: var(--shadow-md); }
.entry-project-bar { width: 4px; height: 36px; border-radius: 4px; flex-shrink: 0; background: var(--border); }
.entry-desc { flex: 1; min-width: 0; }
.entry-desc-text { font-size: .9rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-desc-text.empty { color: var(--text-muted); font-style: italic; }
.entry-meta { display: flex; align-items: center; gap: .5rem; margin-top: .2rem; flex-wrap: wrap; }
.entry-project-name { font-size: .75rem; font-weight: 500; }
.entry-time-range { font-size: .75rem; color: var(--text-muted); }
.tag-chip { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: 20px; font-size: .7rem; font-weight: 600; }
.entry-duration { font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--text); min-width: 72px; text-align: right; flex-shrink: 0; }
.entry-actions { display: flex; gap: .3rem; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.entry-card:hover .entry-actions { opacity: 1; }
.entry-action-btn { width: 30px; height: 30px; border: none; border-radius: var(--radius-sm); background: none; color: var(--text-muted); cursor: pointer; font-size: .9rem; display: flex; align-items: center; justify-content: center; transition: .15s; }
.entry-action-btn:hover { background: var(--primary-light); color: var(--primary); }
.entry-action-btn.danger:hover { background: #fee2e2; color: var(--danger); }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }
.empty-state p { font-size: .9rem; }

/* ===== REPORTS ===== */
.report-filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: .3rem; flex: 1; min-width: 130px; }
.filter-group label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.filter-group input, .filter-group select { padding: .5rem .75rem; font-size: .85rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stat-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--primary); }
.report-section { margin-bottom: 1.5rem; }
.report-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: .75rem; }
.bar-item { margin-bottom: .6rem; }
.bar-label { display: flex; justify-content: space-between; font-size: .8rem; margin-bottom: .25rem; }
.bar-label-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; display: flex; align-items: center; gap: .4rem; }
.bar-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 4px; transition: width .4s ease; }

/* ===== TABLES ===== */
.mgmt-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
.mgmt-table th { padding: .7rem 1rem; font-size: .75rem; font-weight: 700; color: var(--text-muted); text-align: left; text-transform: uppercase; letter-spacing: .05em; background: var(--bg); border-bottom: 1px solid var(--border); }
.mgmt-table td { padding: .85rem 1rem; font-size: .875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mgmt-table tr:last-child td { border-bottom: none; }
.mgmt-table tr:hover td { background: var(--bg); }
.color-dot    { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.color-dot-lg { width: 18px; height: 18px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ===== MODAL ===== */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
#modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column;
}
.modal-header { padding: 1.25rem 1.5rem .75rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border: none; background: none; font-size: 1.2rem; cursor: pointer; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: .15s; }
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body   { padding: 1.25rem 1.5rem; flex: 1; }
.modal-footer { padding: .75rem 1.5rem 1.25rem; display: flex; gap: .75rem; justify-content: flex-end; border-top: 1px solid var(--border); }

/* ===== DROPDOWN ===== */
.dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 500; max-height: 280px; overflow-y: auto; padding: .3rem 0; }
.dropdown-item { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; cursor: pointer; font-size: .85rem; transition: background .1s; }
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.selected { color: var(--primary); font-weight: 600; }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: #1e293b; color: #f1f5f9; padding: .75rem 1.25rem; border-radius: var(--radius-sm); font-size: .875rem; box-shadow: var(--shadow-md); animation: slideIn .2s ease; display: flex; align-items: center; gap: .5rem; max-width: 320px; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== LOADING ===== */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 3rem; }

/* ===== FAB ===== */
.fab { position: fixed; bottom: 1.5rem; right: 1.5rem; width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff; border: none; font-size: 1.4rem; cursor: pointer; box-shadow: 0 4px 12px rgba(99,102,241,.4); display: flex; align-items: center; justify-content: center; transition: .2s; z-index: 50; }
.fab:hover { background: var(--primary-dark); transform: scale(1.05); }

.row { display: flex; gap: .75rem; }
.row > * { flex: 1; }

/* ===== MOBILE ===== */
#menu-toggle { display: none; position: fixed; top: .75rem; left: .75rem; z-index: 200; background: var(--sidebar-bg); color: #fff; border: none; border-radius: var(--radius-sm); width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; align-items: center; justify-content: center; }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }

@media (max-width: 768px) {
  #menu-toggle { display: flex; }
  #sidebar { position: fixed; top: 0; left: 0; height: 100%; transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay.open { display: block; }
  #timer-bar { padding: .75rem 1rem .75rem 3.5rem; }
  #timer-display { font-size: 1.1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  #content-area { padding: 1rem; }
  .entry-actions { opacity: 1; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-box { padding: 1.75rem; }
  .timer-project-btn, .timer-tags-btn { display: none; }
}
