/* ─────────────────────────────────────────────────────────
   LEMON THINK CRM — Sistema de diseño
   Paleta: negro mate + amarillo limón + blanco roto
   Tipografía UI: Syne (display) + DM Sans (texto)
───────────────────────────────────────────────────────── */

/* ── Variables ─────────────────────────────────────────── */
:root {
    --sidebar-bg:     #111318;
    --sidebar-hover:  #1e2028;
    --sidebar-active: rgba(212, 230, 0, 0.12);
    --accent:         #d4e600;
    --accent-dark:    #b5c400;
    --accent-text:    #111318;

    --bg:             #f4f4f0;
    --surface:        #ffffff;
    --surface-alt:    #f9f9f6;

    --text:           #111318;
    --text-muted:     #6b6f7a;
    --text-light:     #9ca3af;
    --border:         #e5e5e0;
    --border-strong:  #d0d0cb;

    --green:   #22c55e;
    --amber:   #f59e0b;
    --red:     #ef4444;
    --blue:    #3b82f6;

    --radius:  10px;
    --radius-sm: 6px;
    --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.10);

    --font-display: 'Syne', sans-serif;
    --font-body:    'DM Sans', sans-serif;

    --sidebar-width: 240px;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* ── Layout principal ───────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    padding: 32px 36px;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar__logo {
    width: 34px; height: 34px;
    background: var(--accent);
    color: var(--accent-text);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.sidebar__brandname {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    letter-spacing: -0.3px;
}

/* Empresa selector */
.sidebar__empresa-switch,
.sidebar__empresa-label {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.empresa-select {
    width: 100%;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--radius-sm);
    color: #ddd;
    font-family: var(--font-body);
    font-size: 12.5px;
    padding: 6px 10px;
    cursor: pointer;
    outline: none;
}

.sidebar__empresa-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar__empresa-label span {
    font-size: 13px;
    font-weight: 500;
    color: #ddd;
}
.sidebar__empresa-label small {
    font-size: 11px;
    color: var(--text-muted);
}

/* Nav links */
.sidebar__nav {
    flex: 1;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: rgba(255,255,255,.6);
    transition: background .15s, color .15s;
}

.nav-item svg {
    width: 17px; height: 17px;
    flex-shrink: 0;
    opacity: .7;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: rgba(255,255,255,.9);
}

.nav-item--active {
    background: var(--sidebar-active);
    color: var(--accent);
}
.nav-item--active svg { opacity: 1; }

.nav-separator {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: 8px 0;
}

/* Footer sidebar */
.sidebar__footer {
    padding: 16px 16px;
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar__user {
    display: flex; align-items: center; gap: 8px;
    flex: 1; min-width: 0;
}

.sidebar__avatar {
    width: 32px; height: 32px;
    background: rgba(212, 230, 0, 0.2);
    color: var(--accent);
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar__user-info {
    display: flex; flex-direction: column;
    min-width: 0;
}
.sidebar__user-name {
    font-size: 12.5px; font-weight: 500; color: #ddd;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user-role {
    font-size: 11px; color: var(--text-muted);
    text-transform: capitalize;
}

.logout-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    color: rgba(255,255,255,.4);
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { background: rgba(239,68,68,.15); color: var(--red); }

/* ── Page header ────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}

.page-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}

/* ── Cards / Surface ────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card__body { padding: 24px; }
.card__header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card__title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ── Botones ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    line-height: 1;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn--primary {
    background: var(--accent);
    color: var(--accent-text);
}
.btn--primary:hover { background: var(--accent-dark); }

.btn--outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.btn--outline:hover { background: var(--surface-alt); border-color: var(--text); }

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn--ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn--danger {
    background: rgba(239,68,68,.1);
    color: var(--red);
}
.btn--danger:hover { background: var(--red); color: #fff; }

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

/* ── Formularios ────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-col-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212,230,0,.15);
    background: var(--surface);
}
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.5; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
.form-check-label { font-size: 13.5px; font-weight: 500; }

.form-hint { font-size: 12px; color: var(--text-muted); }

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* ── Tabla ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

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

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-alt); }

.data-table .actions { display: flex; gap: 6px; }

.table-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge--green  { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge--amber  { background: rgba(245,158,11,.12); color: #d97706; }
.badge--red    { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge--blue   { background: rgba(59,130,246,.12); color: #2563eb; }
.badge--gray   { background: rgba(107,114,128,.1); color: #6b7280; }

/* ── Flash messages ─────────────────────────────────────── */
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}
.flash--success { background: rgba(34,197,94,.1); color: #16a34a; border: 1px solid rgba(34,197,94,.2); }
.flash--error   { background: rgba(239,68,68,.1); color: #dc2626; border: 1px solid rgba(239,68,68,.2); }
.flash--info    { background: rgba(59,130,246,.1); color: #2563eb; border: 1px solid rgba(59,130,246,.2); }
.flash__close   { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; color: inherit; opacity: .6; }

/* ── Dashboard stats ────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow);
}

.stat-card__label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card__value {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text);
    line-height: 1;
}

.stat-card__sub {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-card--accent { border-left: 3px solid var(--accent); }
.stat-card--green  { border-left: 3px solid var(--green); }
.stat-card--amber  { border-left: 3px solid var(--amber); }

/* ── Dashboard doble columna ────────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ── Ficha de detalle ───────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.detail-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.detail-item:nth-child(odd) { padding-right: 24px; }
.detail-item:nth-child(even) { padding-left: 24px; border-left: 1px solid var(--border); }

.detail-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.detail-value { font-size: 14px; font-weight: 500; }

/* ── Login ──────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 44px 48px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 36px;
}

.login-logo-icon {
    width: 42px; height: 42px;
    background: var(--accent);
    color: var(--accent-text);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
}

.login-logo-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.5px;
}

.login-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}
.login-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }

.login-error {
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.2);
    color: #dc2626;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 18px;
}

/* ── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb__sep { opacity: .4; }
.breadcrumb__current { color: var(--text); font-weight: 500; }

/* ── Utilidades ─────────────────────────────────────────── */
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-right { text-align: right; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.font-mono { font-family: 'Courier New', monospace; font-size: 13px; }

/* ── Responsive básico ──────────────────────────────────── */
@media (max-width: 900px) {
    :root { --sidebar-width: 0px; }
    .sidebar { display: none; }
    .main { padding: 20px 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .dash-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-item:nth-child(even) { padding-left: 0; border-left: none; }
}
