/* ============================================================
   VÖLIÁ SYSTEMS — Estilos base
   Paleta: dorado (#c9a24b) / negro / grises, modo oscuro y claro
   ============================================================ */

:root {
    --gold: #c9a24b;
    --gold-soft: #e3c785;
    --gold-dim: #8a6f31;
    --radius: 10px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Georgia', 'Times New Roman', serif;
}

/* ---------- MODO OSCURO (por defecto) ---------- */
:root,
[data-theme="dark"] {
    --bg: #0d0d0d;
    --bg-panel: #161616;
    --bg-panel-2: #1e1e1e;
    --border: #2a2a2a;
    --text: #ededed;
    --text-dim: #9a9a9a;
    --success: #4caf82;
    --warning: #d9a441;
    --danger: #d9634a;
    --info: #6f8fd9;
}

/* ---------- MODO CLARO ---------- */
[data-theme="light"] {
    --bg: #f7f5f0;
    --bg-panel: #ffffff;
    --bg-panel-2: #f1efe8;
    --border: #e2ddce;
    --text: #1c1c1c;
    --text-dim: #6b6b6b;
    --success: #2f8f63;
    --warning: #b3821f;
    --danger: #b8442e;
    --info: #3f5fb0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background .2s ease, color .2s ease;
}

a { color: inherit; text-decoration: none; }

/* ---------- LAYOUT ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
}

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

.sidebar-logo-img {
    max-width: 100%;
    height: auto;
    max-height: 110px;
    object-fit: contain;
}

.nav-group { padding: 0 12px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--bg-panel-2); color: var(--text); }
.nav-item.active {
    background: rgba(201,162,75,0.12);
    color: var(--gold);
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 24px 0;
    border-top: 1px solid var(--border);
}

/* ---------- TOPBAR ---------- */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--bg-panel);
}
.topbar h1 {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 500;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }

.theme-toggle {
    width: 40px; height: 24px;
    border-radius: 20px;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    position: relative;
    cursor: pointer;
}
.theme-toggle::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--gold);
    transition: transform .2s ease;
}
[data-theme="light"] .theme-toggle::after { transform: translateX(16px); }

.content { padding: 28px; }

/* ---------- CARDS / KPIs ---------- */
.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 24px;
}
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.card .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.card .value {
    font-size: 26px;
    font-family: var(--font-serif);
    color: var(--gold);
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}
.panel h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ---------- TABLES ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: rgba(76,175,130,.15); color: var(--success); }
.badge-warning { background: rgba(217,164,65,.15); color: var(--warning); }
.badge-danger  { background: rgba(217,99,74,.15); color: var(--danger); }
.badge-info    { background: rgba(111,143,217,.15); color: var(--info); }

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-panel-2);
    color: var(--text);
    font-size: 13.5px;
    cursor: pointer;
    font-family: var(--font);
}
.btn-gold {
    background: linear-gradient(135deg, var(--gold-soft), var(--gold-dim));
    color: #14110a;
    border: none;
    font-weight: 600;
}
.btn:hover { filter: brightness(1.08); }

/* ---------- FORMS ---------- */
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-panel-2);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
}
label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }

/* ---------- FICHAJE WIDGET ---------- */
.fichaje-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.fichaje-timer {
    font-family: var(--font-serif);
    font-size: 32px;
    color: var(--gold);
}
.fichaje-actions { display: flex; gap: 10px; }

/* ---------- ASISTENTE IA (widget flotante) ---------- */
.ai-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-soft), var(--gold-dim));
    border: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #14110a;
}
.ai-widget-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 340px;
    max-height: 480px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0,0,0,0.35);
    display: none;
    flex-direction: column;
    z-index: 999;
    overflow: hidden;
}
.ai-widget-panel.open { display: flex; }
.ai-widget-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    color: var(--gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ai-widget-header button {
    background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px;
}
.ai-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
    max-height: 340px;
}
.ai-msg { padding: 8px 12px; border-radius: var(--radius); max-width: 85%; line-height: 1.4; }
.ai-msg-user { background: var(--gold-dim); color: #14110a; align-self: flex-end; }
.ai-msg-bot { background: var(--bg-panel-2); color: var(--text); align-self: flex-start; }
.ai-widget-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}
.ai-widget-input input {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
}
.ai-widget-input button {
    background: var(--gold);
    border: none;
    border-radius: var(--radius);
    padding: 0 14px;
    color: #14110a;
    font-weight: 600;
    cursor: pointer;
}

/* ---------- MODALES ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 480px;
    max-width: 92vw;
    max-height: 88vh;
    overflow-y: auto;
    padding: 0;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
}
.modal-header button { background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; }
.modal-box form { padding: 20px; }

/* ---------- AGENDA: CALENDARIO SEMANAL ---------- */
.agenda-grid {
    display: grid;
    grid-template-columns: 50px repeat(7, 1fr);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.agenda-grid-corner { background: var(--bg-panel-2); border-bottom: 1px solid var(--border); }
.agenda-day-header {
    background: var(--bg-panel-2);
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    text-align: center;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-dim);
}
.agenda-day-header span { display: block; text-transform: uppercase; letter-spacing: .5px; }
.agenda-day-header strong { font-family: var(--font-serif); font-size: 16px; color: var(--text); }
.agenda-day-header.is-today strong { color: var(--gold); }
.agenda-hour-label {
    font-size: 11px;
    color: var(--text-dim);
    text-align: right;
    padding: 4px 6px;
    border-top: 1px solid var(--border);
}
.agenda-cell {
    min-height: 42px;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    padding: 2px;
}
.agenda-task {
    background: rgba(201,162,75,0.12);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11px;
    margin-bottom: 2px;
    color: var(--text);
}
.agenda-task a { color: var(--gold); text-decoration: none; }

/* ---------- KANBAN / PIPELINE COLUMNAS ---------- */
.kanban-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.kanban-col-actions { display: flex; gap: 4px; }
.kanban-col-actions button {
    background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px;
}
.kanban-col-actions button:hover { color: var(--gold); }

/* ---------- CLIENTES: DOCS ---------- */
.doc-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    background: var(--bg-panel-2);
    padding: 2px 8px;
    border-radius: 12px;
    margin: 2px 4px 2px 0;
}
.doc-chip a { color: var(--gold); }
.doc-chip .remove { color: var(--danger); cursor: pointer; }

.tipo-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tipo-tabs a {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.tipo-tabs a.active { background: var(--gold); color: #14110a; border-color: var(--gold); font-weight: 600; }

/* ---------- LOGIN ---------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 20%, #1c1a12, #0d0d0d 70%);
}
.login-card {
    width: 380px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
}
.login-card h1 {
    font-family: var(--font-serif);
    color: var(--gold);
    font-size: 24px;
    margin-bottom: 4px;
}
.login-card p.subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.error-msg {
    background: rgba(217,99,74,.12);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}
