/* =============================================
   TimeTracker Pro - Design System
   ============================================= */

:root {
    /* Colors */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16162a;
    --bg-card-hover: #1e1e3a;
    --bg-input: #1e1e36;
    --bg-sidebar: #12121f;

    --text-primary: #e8e8f0;
    --text-secondary: #9ca3b4;
    --text-muted: #6b7280;

    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --border: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(99, 102, 241, 0.5);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);

    --sidebar-width: 240px;
    --topbar-height: 64px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 14px; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 24px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 40px; height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; color: white;
    box-shadow: 0 0 20px var(--accent-glow);
}

.brand-text h1 { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.brand-text span { font-size: 0.75rem; color: var(--accent-light); font-weight: 600; letter-spacing: 2px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500; font-size: 0.93rem;
    transition: var(--transition);
    text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); text-decoration: none; }

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent-light);
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item i { font-size: 1.25rem; width: 22px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.sidebar-version { font-size: 0.75rem; color: var(--text-muted); }

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(12px);
}

.topbar-title { font-size: 1.15rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 10px; }
.menu-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.4rem; cursor: pointer; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit; font-size: 0.875rem; font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-icon {
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent; border: none;
    color: var(--text-secondary); cursor: pointer;
    transition: var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.btn-icon.danger:hover { color: var(--danger); }

/* ===== Views ===== */
.view-container { padding: 24px; flex: 1; }
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent-gradient);
}

.stat-card:hover { transform: translateY(-2px); border-color: var(--border-focus); }

.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; margin: 6px 0 2px; }
.stat-card .stat-sub { font-size: 0.8rem; color: var(--text-secondary); }

.stat-card .stat-icon {
    position: absolute; top: 16px; right: 16px;
    width: 40px; height: 40px;
    background: var(--accent-glow);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: var(--accent-light);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}

.card-header h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-header h3 i { color: var(--accent-light); }
.card-body { padding: 20px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ===== Chart bars ===== */
.client-bars { display: flex; flex-direction: column; gap: 16px; }

.client-bar-item { display: flex; flex-direction: column; gap: 6px; }
.client-bar-label { display: flex; justify-content: space-between; font-size: 0.85rem; }
.client-bar-label span:last-child { color: var(--text-muted); }

.client-bar-track {
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    overflow: hidden;
}

.client-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

/* ===== Monthly Canvas ===== */
.chart-card .card-body { min-height: 220px; }
canvas { width: 100% !important; height: 200px !important; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }

.th-check { width: 36px; }
.th-check input, .table td input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ===== Status Badges ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    text-transform: capitalize;
}

.badge-pendiente { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-reportado { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.badge-facturado { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.badge-pagado { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-por_catalogar { background: rgba(249, 115, 22, 0.15); color: #fb923c; border: 1px solid rgba(249,115,22,.3); }

/* ===== Filters Bar ===== */
.filters-bar {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.filter-group { flex: 1; min-width: 140px; }

/* ===== Entries Summary ===== */
.entries-summary {
    display: flex; gap: 20px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.entries-summary .sum-item { display: flex; align-items: center; gap: 6px; }
.entries-summary .sum-value { font-weight: 700; color: var(--text-primary); }

/* ===== Batch Actions ===== */
.batch-actions {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 20px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateX(-50%) translateY(20px); opacity: 0; } }

#selected-count { font-weight: 600; color: var(--accent-light); }

/* ===== Forms / Inputs ===== */
.input {
    width: 100%;
    padding: 9px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: var(--transition);
    outline: none;
}

.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input::placeholder { color: var(--text-muted); }

select.input { cursor: pointer; }
textarea.input { resize: vertical; }

.input-color { padding: 4px; height: 40px; cursor: pointer; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== Modals ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 600px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

.modal-sm { max-width: 420px; }

@keyframes modalIn { from { transform: scale(0.95) translateY(10px); opacity: 0; } }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.modal-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none; background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 8px; }

/* ===== Clients Grid ===== */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.client-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.client-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
}

.client-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.client-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.client-card-name { font-size: 1.15rem; font-weight: 700; }
.client-card-rate { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

.client-card-actions { display: flex; gap: 4px; }

.client-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.client-stat { text-align: center; padding: 10px; background: rgba(255,255,255,0.03); border-radius: var(--radius-sm); }
.client-stat-val { font-size: 1.3rem; font-weight: 700; }
.client-stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }

.client-subs { border-top: 1px solid var(--border); padding-top: 14px; }
.client-subs-title { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; font-weight: 600; }

.sub-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 2px;
    transition: var(--transition);
}
.sub-tag:hover { background: rgba(255,255,255,0.08); }

.sub-tag .remove-sub {
    cursor: pointer; color: var(--text-muted);
    font-size: 0.65rem;
    transition: var(--transition);
}
.sub-tag .remove-sub:hover { color: var(--danger); }

.btn-add-sub {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border: 1px dashed var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: none;
    cursor: pointer;
    margin: 2px;
    transition: var(--transition);
}
.btn-add-sub:hover { border-color: var(--accent); color: var(--accent-light); }

/* ===== Toasts ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }

.toast {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 0.875rem;
    display: flex; align-items: center; gap: 8px;
    animation: slideIn 0.3s ease;
    min-width: 260px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }

/* ===== Amount Formatting ===== */
.amount { font-variant-numeric: tabular-nums; }
.text-success { color: var(--success); }
.text-muted { color: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .topbar-actions { gap: 6px; }
    .btn span { display: none; }
    .filters-bar { flex-direction: column; }
    .filter-group { min-width: 100%; }
}
