/* =============================================================================
   CRM Airrey - Main Stylesheet
   Colores y tipografía inspirados en airrey.com (página web pública).
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* -------------------------------------------------- Design tokens (theme) */

:root, :root[data-theme="light"] {
    --bg-page: #fafafa;
    --bg-surface: #ffffff;
    --bg-subtle: #f4f4f3;
    --bg-hover: #ececec;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;
    --border: rgba(0, 0, 0, 0.07);
    --border-strong: rgba(0, 0, 0, 0.14);

    /* Brand Air Rey */
    --brand-orange: #ef8a4d;
    --brand-orange-dark: #e6743a;
    --brand-green: #7cb342;
    --brand-green-dark: #5a8f4f;
    --brand-blue: #3aa6ce;
    --brand-teal: #1a5d5e;

    /* Accent = naranja Air Rey (primary CTAs) */
    --accent: #ef8a4d;
    --accent-bg: #fdf0e6;
    --accent-text: #b86432;

    /* Estados */
    --success: #5a8f4f;
    --success-bg: #ecf3df;
    --warning: #b8801a;
    --warning-bg: #fbeed7;
    --danger: #c0392b;
    --danger-bg: #fbe7e7;
    --info: #2d7faa;
    --info-bg: #e2edf8;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 6px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
}

:root[data-theme="dark"] {
    --bg-page: #14140f;
    --bg-surface: #1c1c19;
    --bg-subtle: #242420;
    --bg-hover: #2c2c28;
    --text-primary: #ecebe6;
    --text-secondary: #a8a59e;
    --text-tertiary: #6e6c65;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);

    /* Brand Air Rey (más vivos en oscuro) */
    --brand-orange: #f5996a;
    --brand-orange-dark: #ef8a4d;
    --brand-green: #97c459;
    --brand-green-dark: #7cb342;
    --brand-blue: #5ab8d8;
    --brand-teal: #4a9697;

    /* Accent en oscuro: naranja más suave */
    --accent: #f5996a;
    --accent-bg: #3a2412;
    --accent-text: #fcb98c;

    --success: #97c459;
    --success-bg: #1f3812;
    --warning: #efb05a;
    --warning-bg: #3d2a0a;
    --danger: #e07a7a;
    --danger-bg: #3a1818;
    --info: #85b7eb;
    --info-bg: #143258;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}
/* -------------------------------------------------- Base */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; margin: 0 0 12px 0; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 22px; letter-spacing: -0.01em; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }

p { margin: 0 0 12px 0; color: var(--text-secondary); }

code, pre {
    font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
    font-size: 12.5px;
    background: var(--bg-subtle);
    padding: 1px 5px;
    border-radius: 3px;
}

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* -------------------------------------------------- Layout */

.vendedor-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    margin-bottom: 24px;
}
.page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
}
.page-meta {
    font-size: 13px;
    color: var(--text-tertiary);
}
.page-meta b { color: var(--text-secondary); }

/* -------------------------------------------------- Botones */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    min-height: 36px;
    font-family: inherit;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-expand {
    width: 100%;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-subtle);
    border-color: var(--border);
}

/* -------------------------------------------------- Tags / badges */

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    background: var(--bg-subtle);
    color: var(--text-secondary);
}
.tag-success { background: var(--success-bg); color: var(--success); }
.tag-warning, .tag-pending { background: var(--warning-bg); color: var(--warning); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-info { background: var(--info-bg); color: var(--info); }
.tag-neutral { background: var(--bg-subtle); color: var(--text-tertiary); }
.tag-mini { padding: 1px 6px; font-size: 10px; }

/* -------------------------------------------------- Cards */

.v-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.v-card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.v-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0; }
.v-card-body { padding: 18px; }

.v-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.v-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 768px) {
    .v-grid-2, .v-grid-3 { grid-template-columns: 1fr; }
}

/* -------------------------------------------------- Tablas */

.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.table-scroll { overflow-x: auto; max-width: 100%; }

.v-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.v-table thead tr { background: var(--bg-subtle); }
.v-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
.v-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
}
.v-table tbody tr:hover { background: var(--bg-hover); }
.v-table tbody tr:last-child td { border-bottom: none; }
.v-table th.right, .v-table td.right { text-align: right; }
.v-table code { background: var(--bg-subtle); padding: 1px 5px; border-radius: 3px; font-size: 11.5px; }
.v-table .num { font-variant-numeric: tabular-nums; font-weight: 600; }

.v-row-highlight { background: var(--accent-bg); }
.v-row-highlight:hover { background: var(--accent-bg); }

/* -------------------------------------------------- Forms */

input, select, textarea, button {
    font-family: inherit;
    font-size: 14px;
}
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], input[type="time"], input[type="password"], input[type="search"],
select, textarea {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 8px 12px;
    transition: border-color 0.15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; display: block; margin-bottom: 4px; }

.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.filters-form > * { flex: 0 0 auto; }
.filters-form label { display: block; font-size: 11.5px; color: var(--text-tertiary); margin-bottom: 4px; }
.filters-form input, .filters-form select { min-width: 140px; }

/* -------------------------------------------------- Detail rows */

.detail-row {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-tertiary); min-width: 140px; }
.detail-row .value { color: var(--text-primary); flex: 1; }

/* -------------------------------------------------- Empty state */

.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
}
.empty h3 { color: var(--text-secondary); margin-bottom: 6px; }

/* -------------------------------------------------- File inputs / preview */

.file-input-preview { display: flex; align-items: center; gap: 10px; }
.file-meta { font-size: 12px; color: var(--text-tertiary); }
.file-preview-inline { max-width: 80px; max-height: 80px; border-radius: 4px; border: 1px solid var(--border); }

/* -------------------------------------------------- Utility */

.muted { color: var(--text-tertiary); }
.brand { font-weight: 600; }
.fill-half { fill: currentColor; opacity: 0.5; }
.icon-fallback { display: inline-flex; align-items: center; justify-content: center; }
.error { color: var(--danger); font-size: 12px; }
.info { color: var(--info); }
.danger { color: var(--danger); }

/* -------------------------------------------------- Calendar mini-cells */

.cal-cell-today { background: var(--accent-bg) !important; }
.cal-cell-weekend { background: var(--bg-subtle); }

/* -------------------------------------------------- Scrollbar (subtle) */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* -------------------------------------------------- Theme toggle (botones SVG) */

.theme-toggle {
    display: inline-flex;
    gap: 0;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px;
}
.theme-toggle button {
    width: 30px;
    height: 30px;
    padding: 5px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: all 0.15s ease;
}
.theme-toggle button:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.theme-toggle button.active {
    background: var(--bg-surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.theme-toggle button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.theme-toggle button svg .fill-half {
    fill: currentColor;
    stroke: none;
}

/* -------------------------------------------------- Stats / KPI grid */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.stat-label {
    font-size: 11.5px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }
.stat-value.info    { color: var(--info); }
.stat-value.accent  { color: var(--accent); }
.stat-hint {
    font-size: 11.5px;
    color: var(--text-tertiary);
}

/* -------------------------------------------------- Form fields (v-field) */

.v-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.v-field label {
    font-size: 11.5px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/*
 * v-field-input es solo un wrapper SIN estilos visuales propios.
 * El input/select/textarea adentro es el que se ve como una caja normal.
 * Así evitamos el "doble cuadro" cuando se anidan.
 */
.v-field-input {
    display: block;
    width: 100%;
}
.v-field-input > input,
.v-field-input > select,
.v-field-input > textarea,
.v-field > input,
.v-field > select,
.v-field > textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.v-field-input > input:focus,
.v-field-input > select:focus,
.v-field-input > textarea:focus,
.v-field > input:focus,
.v-field > select:focus,
.v-field > textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.v-field-input > input::placeholder,
.v-field-input > textarea::placeholder,
.v-field > input::placeholder,
.v-field > textarea::placeholder { color: var(--text-tertiary); }

/* -------------------------------------------------- Alerts (v-alert) */

.v-alert {
    padding: 12px 14px;
    border: 1px solid;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.v-alert.info    { background: var(--info-bg);    border-color: var(--info);    color: var(--info); }
.v-alert.success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.v-alert.warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.v-alert.danger  { background: var(--danger-bg);  border-color: var(--danger);  color: var(--danger); }

/* -------------------------------------------------- Login layout fallback */

.vlogin-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
    padding: 24px;
}
.vlogin-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
}
.vlogin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.vlogin-logo-mark {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}
.vlogin-brand-text { display: flex; flex-direction: column; }
.vlogin-brand-name { font-weight: 700; font-size: 16px; color: var(--text-primary); }
.vlogin-brand-sub  { font-size: 12px; color: var(--text-tertiary); }
.vlogin-title { font-size: 22px; margin-bottom: 6px; }
.vlogin-sub   { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.vlogin-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
}
.vlogin-field { margin-bottom: 14px; }
.vlogin-field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; }
.vlogin-field input { width: 100%; box-sizing: border-box; }
.vlogin-submit { width: 100%; margin-top: 6px; padding: 12px; font-size: 14px; }
.vlogin-footer { margin-top: 18px; text-align: center; font-size: 12px; color: var(--text-tertiary); }

/* =============================================================================
   Estilos adicionales — HCP y módulos admin
   ============================================================================= */

/* -------------------------------------------------- Stat modifiers en la card */

.stat.success .stat-value { color: var(--success); }
.stat.success .stat-label { color: var(--success); opacity: 0.85; }
.stat.warning .stat-value { color: var(--warning); }
.stat.warning .stat-label { color: var(--warning); opacity: 0.85; }
.stat.danger  .stat-value { color: var(--danger); }
.stat.danger  .stat-label { color: var(--danger); opacity: 0.85; }
.stat.info    .stat-value { color: var(--info); }
.stat.info    .stat-label { color: var(--info); opacity: 0.85; }

/* -------------------------------------------------- Page actions (botones header) */

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 18px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header > div:first-child { flex: 1; min-width: 300px; }

/* -------------------------------------------------- Status dot */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
    box-shadow: 0 0 0 2px var(--success-bg);
}

/* -------------------------------------------------- Tabla plain (HCP) dentro de table-card */

.table-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
.table-card thead tr { background: var(--bg-subtle); }
.table-card th {
    text-align: left;
    padding: 9px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-subtle);
    z-index: 2;
}
.table-card td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
    white-space: nowrap;
}
.table-card tbody tr:hover { background: var(--bg-hover); }
.table-card tbody tr:last-child td { border-bottom: none; }
.table-card th.right, .table-card td.right { text-align: right; }
.table-card .num {
    font-variant-numeric: tabular-nums;
    font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
    font-size: 11.5px;
}
.table-card .truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.table-card .empty-row {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 13.5px;
}

/* Sticky columns (primera y última) */
.table-card th.col-sticky-l,
.table-card td.col-sticky-l {
    position: sticky;
    left: 0;
    background: var(--bg-surface);
    z-index: 1;
    border-right: 1px solid var(--border);
}
.table-card thead th.col-sticky-l { background: var(--bg-subtle); z-index: 3; }
.table-card tbody tr:hover td.col-sticky-l { background: var(--bg-hover); }

.table-card th.col-sticky-r,
.table-card td.col-sticky-r {
    position: sticky;
    right: 0;
    background: var(--bg-surface);
    z-index: 1;
    border-left: 1px solid var(--border);
}
.table-card thead th.col-sticky-r { background: var(--bg-subtle); z-index: 3; }
.table-card tbody tr:hover td.col-sticky-r { background: var(--bg-hover); }

/* -------------------------------------------------- Tag list (HCP categories) */

.tag-list {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* -------------------------------------------------- Pager (paginación HCP) */

.pager {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}
.pager-btn {
    padding: 6px 12px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s ease;
}
.pager-btn:hover { background: var(--bg-hover); text-decoration: none; }
.pager-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}
.pager-info { color: var(--text-tertiary); font-size: 12px; margin: 0 6px; }
.btn-clear {
    color: var(--text-tertiary);
    font-size: 12px;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
}
