/* ========================================================
   CCR Legal — Sistema de Tiempos
   Design system: purpura #6e39e2, navy #121d68, beige #f9f4f2
   Fonts: Cormorant Garamond (headings), DM Sans (body)
   ======================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', 'Segoe UI', sans-serif; background: #f9f4f2; color: #242424; font-size: 14px; }

/* ── Login ── */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #121d68 0%, #2d1b4e 50%, #6e39e2 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 48px 40px; box-shadow: 0 8px 40px rgba(0,0,0,0.2); width: 100%; max-width: 400px; }
.login-card h1 { font-family: 'Cormorant Garamond', serif; font-size: 28px; font-weight: 700; color: #121d68; margin-bottom: 4px; }
.login-card .subtitle { font-size: 13px; color: #757575; margin-bottom: 28px; }
.login-card label { display: block; font-size: 11px; font-weight: 600; color: #616161; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; margin-bottom: 16px; font-family: inherit; }
.login-card input:focus { outline: none; border-color: #6e39e2; box-shadow: 0 0 0 3px rgba(110,57,226,0.12); }
.login-card button { width: 100%; padding: 12px; background: #6e39e2; color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background 0.2s; }
.login-card button:hover { background: #5a2dc5; }
.login-error { background: #fde7e9; color: #e81123; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: none; }

/* ── Layout principal ── */
.app-screen { /* visibilidad controlada por JS inline style */ }
.topbar { background: linear-gradient(135deg, #121d68 0%, #2d1b4e 100%); color: #fff; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.topbar h1 { font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar .user-name { font-size: 13px; opacity: 0.85; }
.topbar .btn-logout { background: rgba(255,255,255,0.12); border: none; color: #fff; padding: 6px 14px; border-radius: 6px; font-size: 12px; cursor: pointer; font-family: inherit; transition: background 0.2s; }
.topbar .btn-logout:hover { background: rgba(255,255,255,0.25); }

/* Timer en topbar */
.timer-bar { display: none; align-items: center; gap: 10px; background: rgba(255,255,255,0.1); padding: 6px 14px; border-radius: 8px; }
.timer-bar.active { display: flex; }
.timer-bar .timer-display { font-family: 'DM Sans', monospace; font-size: 16px; font-weight: 700; color: #4cff9f; }
.timer-bar .timer-matter { font-size: 11px; opacity: 0.8; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-bar .btn-timer-stop { background: #e81123; color: #fff; border: none; padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; cursor: pointer; }

/* ── Navegacion ── */
.nav-tabs { display: flex; background: #fff; border-bottom: 1px solid #e5e0db; padding: 0 24px; gap: 2px; overflow-x: auto; }
.nav-tab { padding: 12px 16px; border: none; background: none; border-bottom: 3px solid transparent; font-size: 13px; font-weight: 600; color: #757575; cursor: pointer; font-family: inherit; white-space: nowrap; transition: all 0.2s; position: relative; }
.nav-tab:hover { color: #6e39e2; }
.nav-tab.active { color: #6e39e2; border-bottom-color: #6e39e2; }
.nav-tab .badge-count { position: absolute; top: 6px; right: 4px; background: #e81123; color: #fff; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 10px; min-width: 16px; text-align: center; }

/* ── Contenido ── */
.content { max-width: 1200px; margin: 0 auto; padding: 24px; }
.panel { display: none; }
.panel.active { display: block; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.panel-header h2 { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 700; color: #121d68; }

/* ── Tarjetas de progreso ── */
.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.progress-card { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 6px rgba(0,0,0,0.05); }
.progress-card .card-title { font-size: 11px; font-weight: 600; color: #757575; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.progress-ring { width: 100px; height: 100px; margin: 0 auto 12px; position: relative; }
.progress-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.progress-ring circle { fill: none; stroke-width: 8; }
.progress-ring .bg { stroke: #ece8e3; }
.progress-ring .fg { stroke: #6e39e2; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.progress-ring .fg.warning { stroke: #f7a800; }
.progress-ring .fg.danger { stroke: #e81123; }
.progress-ring .fg.success { stroke: #107c10; }
.progress-pct { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 22px; font-weight: 700; color: #121d68; }
.progress-details { display: flex; gap: 16px; justify-content: center; }
.progress-detail { text-align: center; }
.progress-detail .label { font-size: 10px; color: #999; text-transform: uppercase; }
.progress-detail .value { font-size: 14px; font-weight: 700; }
.progress-detail .value.billable { color: #107c10; }
.progress-detail .value.non-billable { color: #e81123; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.stat-card .stat-label { font-size: 11px; font-weight: 600; color: #757575; text-transform: uppercase; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; color: #121d68; }
.stat-card .stat-sub { font-size: 12px; color: #999; margin-top: 2px; }

/* ── Tablas ── */
.table-card { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); overflow: hidden; margin-bottom: 24px; }
.table-card h3 { padding: 16px 20px 12px; font-family: 'Cormorant Garamond', serif; font-size: 16px; font-weight: 700; color: #121d68; border-bottom: 1px solid #f0ebe6; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #faf7f5; padding: 10px 14px; text-align: left; font-weight: 600; color: #616161; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }
td { padding: 10px 14px; border-top: 1px solid #f0ebe6; }
tr:hover { background: #faf7f5; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.badge-active { background: #e6f4ea; color: #107c10; }
.badge-inactive { background: #fde7e9; color: #e81123; }
.badge-on-hold { background: #fff3e0; color: #f57c00; }
.badge-billable { background: #e6f4ea; color: #107c10; }
.badge-non-billable { background: #f0ebe6; color: #757575; }
.badge-hourly { background: #e8f0fe; color: #1967d2; }
.badge-fixed { background: #fce8e6; color: #c5221f; }
.badge-pro-bono { background: #f0ebe6; color: #757575; }
.badge-scriba { background: #f3e8ff; color: #6e39e2; }

/* ── Botones ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.btn-primary { background: #6e39e2; color: #fff; }
.btn-primary:hover { background: #5a2dc5; }
.btn-secondary { background: #f0ebe6; color: #121d68; }
.btn-secondary:hover { background: #e5e0db; }
.btn-danger { background: #fde7e9; color: #e81123; }
.btn-danger:hover { background: #fcd0d4; }
.btn-success { background: #e6f4ea; color: #107c10; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-icon { background: none; border: none; padding: 4px; cursor: pointer; color: #757575; font-size: 16px; }
.btn-icon:hover { color: #6e39e2; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Formularios ── */
.form-row { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 180px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: #616161; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-family: inherit; background: #fff; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #6e39e2; box-shadow: 0 0 0 3px rgba(110,57,226,0.1); }
.form-group textarea { resize: vertical; min-height: 60px; }

/* Toggle switch */
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { display: none; }
.toggle-slider { width: 36px; height: 20px; background: #d1d5db; border-radius: 10px; position: relative; transition: background 0.2s; }
.toggle-slider::after { content: ''; position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: transform 0.2s; }
.toggle input:checked + .toggle-slider { background: #6e39e2; }
.toggle input:checked + .toggle-slider::after { transform: translateX(16px); }
.toggle-label { font-size: 13px; font-weight: 500; }

/* ── Cronometro widget ── */
.stopwatch-card { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 6px rgba(0,0,0,0.05); margin-bottom: 24px; border: 2px solid transparent; }
.stopwatch-card.running { border-color: #6e39e2; background: linear-gradient(135deg, #faf7ff 0%, #fff 100%); }
.stopwatch-display { font-size: 48px; font-weight: 700; color: #121d68; text-align: center; font-family: 'DM Sans', monospace; margin: 16px 0; letter-spacing: 2px; }
.stopwatch-controls { display: flex; gap: 8px; justify-content: center; }

/* ── Registro rapido ── */
.quick-matters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.quick-matter { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #e5e0db; border-radius: 8px; padding: 8px 14px; font-size: 12px; cursor: pointer; transition: all 0.2s; }
.quick-matter:hover { border-color: #6e39e2; background: #faf7ff; }
.quick-matter .qm-client { color: #999; font-size: 11px; }
.quick-matter .qm-title { font-weight: 600; color: #121d68; }

/* ── Calendario ── */
.calendar-header { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 16px; }
.calendar-header h3 { font-family: 'Cormorant Garamond', serif; font-size: 18px; color: #121d68; min-width: 180px; text-align: center; }
.calendar-header button { background: #f0ebe6; border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.calendar-header button:hover { background: #e5e0db; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day-header { text-align: center; font-size: 11px; font-weight: 600; color: #999; text-transform: uppercase; padding: 8px 0; }
.calendar-day { background: #fff; border-radius: 8px; min-height: 80px; padding: 8px; cursor: pointer; border: 1px solid #f0ebe6; transition: all 0.2s; }
.calendar-day:hover { border-color: #6e39e2; }
.calendar-day.empty { background: transparent; border: none; cursor: default; }
.calendar-day.today { border-color: #6e39e2; background: #faf7ff; }
.calendar-day .day-num { font-size: 12px; font-weight: 600; color: #757575; margin-bottom: 6px; }
.calendar-day .day-hours { font-size: 16px; font-weight: 700; }
.calendar-day .day-hours.at-goal { color: #107c10; }
.calendar-day .day-hours.near-goal { color: #f7a800; }
.calendar-day .day-hours.below-goal { color: #e81123; }
.calendar-day .day-hours.no-entries { color: #d1d5db; }

/* ── Filtros ── */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: end; }
.filter-bar .form-group { min-width: 140px; flex: unset; }
.filter-bar .form-group input, .filter-bar .form-group select { padding: 7px 10px; font-size: 12px; }

/* ── Paginacion ── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 16px; }
.pagination button { padding: 6px 12px; border: 1px solid #d1d5db; background: #fff; border-radius: 6px; font-size: 12px; cursor: pointer; font-family: inherit; }
.pagination button.active { background: #6e39e2; color: #fff; border-color: #6e39e2; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: #757575; }

/* ── Modales ── */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(18,29,104,0.4); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 32px; max-width: 560px; width: 92%; box-shadow: 0 12px 48px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto; }
.modal h2 { font-family: 'Cormorant Garamond', serif; font-size: 20px; color: #121d68; margin-bottom: 20px; }
.modal .btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

/* ── Sugerencias Scriba ── */
.suggestion-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); margin-bottom: 12px; border-left: 4px solid #6e39e2; }
.suggestion-card.confirmed { border-left-color: #107c10; opacity: 0.6; }
.suggestion-card.dismissed { border-left-color: #d1d5db; opacity: 0.4; }
.suggestion-card .sg-desc { font-size: 14px; font-weight: 600; color: #121d68; margin-bottom: 4px; }
.suggestion-card .sg-case { font-size: 12px; color: #757575; margin-bottom: 10px; }
.suggestion-card .sg-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.suggestion-card .sg-form select, .suggestion-card .sg-form input { padding: 6px 8px; font-size: 12px; border: 1px solid #d1d5db; border-radius: 6px; }
.suggestion-card .sg-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ── Alertas ── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: #e6f4ea; color: #107c10; }
.alert-error { background: #fde7e9; color: #e81123; }
.alert-info { background: #e8f0fe; color: #1967d2; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: #999; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Duration input ── */
.duration-input { display: flex; align-items: center; gap: 4px; }
.duration-input button { width: 28px; height: 28px; border: 1px solid #d1d5db; background: #fff; border-radius: 6px; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.duration-input button:hover { background: #f0ebe6; }
.duration-input input { width: 60px; text-align: center; padding: 6px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-weight: 600; }

/* ── Loading spinner ── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid #d1d5db; border-top-color: #6e39e2; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
    .topbar { padding: 10px 16px; }
    .topbar h1 { font-size: 16px; }
    .nav-tabs { padding: 0 12px; }
    .nav-tab { padding: 10px 12px; font-size: 12px; }
    .content { padding: 16px; }
    .progress-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .form-group { min-width: 100%; }
    .filter-bar { flex-direction: column; }
    .filter-bar .form-group { min-width: 100%; }
    .calendar-grid { gap: 2px; }
    .calendar-day { min-height: 60px; padding: 4px; }
    .calendar-day .day-hours { font-size: 13px; }
    .stopwatch-display { font-size: 36px; }
    .timer-bar .timer-matter { max-width: 100px; }
    .quick-matters { flex-direction: column; }
    .modal { padding: 24px 20px; width: 95%; }
    table { font-size: 12px; }
    th, td { padding: 8px 10px; }
}

@media (max-width: 480px) {
    .progress-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .stopwatch-display { font-size: 28px; }
    .topbar-right { gap: 8px; }
    .timer-bar { padding: 4px 8px; }
}
