/* ============================================================================
   LoyaltyCloud Admin — Sistema de diseño
   Paleta KBeauty: Sand · Ink · Blush · Sage · Gold
   Tipografía: Cormorant Garamond (display) + DM Sans (body)
   ============================================================================ */

:root {
    /* Paleta base */
    --kb-bg: #F7F5F0;
    --kb-bg-card: #FFFFFF;
    --kb-ink: #1C1B18;
    --kb-ink-muted: #5C5A50;
    --kb-blush: #C4897A;
    --kb-blush-soft: #F2E8E5;
    --kb-sand-50: #F7F5F0;
    --kb-sand-100: #EDEAE2;
    --kb-sage: #7A9E8C;
    --kb-gold: #B8986A;

    /* Tipografía */
    --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Espacios y tamaños */
    --kb-radius-sm: 8px;
    --kb-radius: 14px;
    --kb-radius-lg: 20px;
    --kb-shadow: 0 1px 3px rgba(28, 27, 24, 0.04), 0 4px 12px rgba(28, 27, 24, 0.04);
    --kb-shadow-lg: 0 4px 24px rgba(28, 27, 24, 0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--kb-bg);
    color: var(--kb-ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--kb-ink);
    margin: 0 0 16px 0;
}

h1 { font-size: 2.5rem; line-height: 1.1; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }

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

label { display: block; margin-bottom: 8px; font-size: 0.9rem; color: var(--kb-ink-muted); font-weight: 500; }

input[type=text], input[type=email], input[type=number], input[type=password], input[type=date], input[type=tel], select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--kb-sand-100);
    border-radius: var(--kb-radius-sm);
    background: var(--kb-bg-card);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--kb-ink);
    transition: border-color 120ms ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--kb-blush);
    box-shadow: 0 0 0 3px var(--kb-blush-soft);
}

/* ============================================================================
   Layout principal
   ============================================================================ */
.kb-app { display: flex; min-height: 100vh; }
.kb-sidebar {
    width: 240px;
    background: var(--kb-bg-card);
    border-right: 1px solid var(--kb-sand-100);
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.kb-sidebar h1 { font-size: 1.5rem; margin: 0; }
.kb-sidebar-brand { margin-bottom: 24px; display: flex; flex-direction: column; gap: 4px; }
.kb-sidebar-brand span { color: var(--kb-ink-muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.kb-brand-logo { display: block; max-width: 160px; max-height: 64px; object-fit: contain; }
.kb-sidebar-section {
    margin: 18px 14px 0;
    color: color-mix(in srgb, var(--kb-ink-muted) 78%, white);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}
.kb-sidebar-brand + .kb-sidebar-section { margin-top: 0; }
.kb-sidebar a {
    padding: 10px 14px;
    border-radius: var(--kb-radius-sm);
    color: var(--kb-ink-muted);
    font-weight: 500;
    text-decoration: none;
    transition: background 120ms;
}
.kb-sidebar a:hover, .kb-sidebar a.active {
    background: var(--kb-sand-100);
    color: var(--kb-ink);
}
.kb-sidebar .kb-signout { margin-top: auto; color: var(--kb-blush); }

.kb-main { flex: 1; padding: 40px; max-width: 1200px; }

/* ============================================================================
   Cards / Grid
   ============================================================================ */
.kb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.kb-card {
    background: var(--kb-bg-card);
    border: 1px solid var(--kb-sand-100);
    border-radius: var(--kb-radius);
    padding: 24px;
    box-shadow: var(--kb-shadow);
}
.kb-card-label { color: var(--kb-ink-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.kb-card-value { font-family: var(--font-display); font-size: 2.5rem; font-weight: 500; margin-top: 8px; }
.kb-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }

/* ============================================================================
   Tabla
   ============================================================================ */
.kb-table { width: 100%; border-collapse: collapse; background: var(--kb-bg-card); border-radius: var(--kb-radius); overflow: hidden; box-shadow: var(--kb-shadow); }
.kb-table th, .kb-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--kb-sand-100); }
.kb-table th { background: var(--kb-sand-50); color: var(--kb-ink-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.kb-table tr:last-child td { border-bottom: none; }
.kb-table tr:hover td { background: var(--kb-sand-50); }
.kb-table--compact th, .kb-table--compact td { padding: 12px 14px; vertical-align: middle; }
.kb-cell-number { text-align: right !important; white-space: nowrap; }
.kb-cell-center { text-align: center !important; }
.kb-muted { color: var(--kb-ink-muted); }
.kb-text-truncate {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================================
   Botones
   ============================================================================ */
.kb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--kb-radius-sm);
    background: var(--kb-ink);
    color: var(--kb-bg-card);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 120ms, transform 80ms;
}
.kb-btn:hover { opacity: 0.92; }
.kb-btn:active { transform: scale(0.98); }
.kb-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.kb-btn--primary { background: var(--kb-blush); }
.kb-btn--ghost { background: transparent; color: var(--kb-ink); border: 1px solid var(--kb-sand-100); }
.kb-btn--danger { background: #B23B3B; color: #fff; }
.kb-btn--large { font-size: 1.15rem; padding: 18px 32px; min-height: 56px; }
.kb-btn--block { display: flex; width: 100%; }
.kb-btn--small { padding: 8px 12px; font-size: 0.9rem; }
.kb-actions-inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: nowrap; white-space: nowrap; }

/* ============================================================================
   Niveles (badges)
   ============================================================================ */
.kb-level { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em; }
.kb-level--mist { background: #EDEAE2; color: #5C5A50; }
.kb-level--glow { background: #E8F0FB; color: #185FA5; }
.kb-level--radiance { background: #F2E8E5; color: #C4897A; }
.kb-level--neutral { background: #F4F1EA; color: #3D3A36; }
.kb-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.kb-badge--success { background: #ECF3EF; color: var(--kb-sage); }
.kb-badge--warning { background: #FFF4DF; color: var(--kb-gold); }
.kb-badge--muted { background: var(--kb-sand-100); color: var(--kb-ink-muted); }

/* ============================================================================
   PointsDisplay (animación)
   ============================================================================ */
.kb-points {
    font-family: var(--font-display);
    font-size: 4.5rem;
    font-weight: 500;
    line-height: 1;
    color: var(--kb-ink);
    text-align: center;
    animation: kb-pop 380ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes kb-pop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ============================================================================
   Scan page (mobile-first)
   ============================================================================ */
.kb-scan { max-width: 480px; margin: 0 auto; padding: 24px; }
.kb-scan input[type=text], .kb-scan input[type=number] { font-size: 1.5rem; padding: 18px; text-align: center; }
.kb-qr-scanner {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--kb-sand-100);
    border-radius: var(--kb-radius-sm);
    background: var(--kb-bg-card);
}
.kb-qr-video {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--kb-radius-sm);
    background: #111;
}
.kb-qr-scanner p {
    margin: 0;
    color: var(--kb-ink-muted);
    text-align: center;
}

/* ============================================================================
   Quick help
   ============================================================================ */
.kb-help { max-width: 980px; }
.kb-help-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.kb-help-header p { margin: -8px 0 0; }
.kb-help-registration { margin-bottom: 20px; }
.kb-help-registration-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 20px;
    align-items: center;
}
.kb-help-link {
    padding: 12px 14px;
    border: 1px solid var(--kb-sand-100);
    border-radius: var(--kb-radius-sm);
    background: var(--kb-sand-50);
    color: var(--kb-ink);
    font-weight: 700;
    overflow-wrap: anywhere;
}
.kb-help-actions { margin-top: 14px; flex-wrap: wrap; }
.kb-logo-preview {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--kb-sand-100);
    border-radius: var(--kb-radius-sm);
    background: #fff;
}
.kb-logo-preview img {
    display: block;
    width: auto;
    max-width: 160px;
    max-height: 56px;
    object-fit: contain;
}
.kb-logo-preview span {
    color: var(--kb-ink-muted);
    font-size: 0.86rem;
    font-weight: 700;
}
.kb-help-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--kb-sand-100);
    border-radius: var(--kb-radius);
    background: var(--kb-bg-card);
}
.kb-help-qr img {
    width: 152px;
    height: 152px;
    image-rendering: crisp-edges;
}
.kb-help-qr span {
    color: var(--kb-ink-muted);
    font-size: 0.86rem;
    font-weight: 700;
}
.kb-help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}
.kb-help-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 16px;
}
.kb-help-number {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--kb-sand-100);
    color: var(--kb-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
}
.kb-help-card h2,
.kb-help-common h2 { margin-bottom: 10px; }
.kb-help-card ol,
.kb-help-card ul {
    margin: 0 0 16px;
    padding-left: 20px;
}
.kb-help-card li { margin-bottom: 6px; }
.kb-help-common-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.kb-help-common h3 {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 6px;
}
.kb-help-common p {
    margin: 0;
    color: var(--kb-ink-muted);
}
.kb-registration-poster {
    margin: 0 0 20px;
    display: flex;
    justify-content: center;
}
.kb-registration-poster-inner {
    width: min(100%, 480px);
    padding: 36px 30px;
    border: 2px solid var(--kb-blush);
    border-radius: var(--kb-radius-lg);
    background: linear-gradient(180deg, var(--kb-bg-card), var(--kb-sand-50));
    text-align: center;
    box-shadow: var(--kb-shadow);
}
.kb-poster-brand {
    color: var(--kb-blush);
    font-family: var(--font-display);
    font-size: 2rem;
    line-height: 1;
    font-weight: 700;
}
.kb-poster-kicker {
    margin: 8px 0 22px;
    color: var(--kb-ink-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.kb-registration-poster h2 {
    max-width: 360px;
    margin: 0 auto 12px;
    font-size: 2.2rem;
}
.kb-registration-poster p {
    max-width: 340px;
    margin: 0 auto 24px;
    color: var(--kb-ink-muted);
}
.kb-registration-poster img {
    width: min(72vw, 280px);
    height: min(72vw, 280px);
    padding: 12px;
    border-radius: var(--kb-radius);
    background: #fff;
}
.kb-registration-poster strong {
    display: block;
    margin-top: 14px;
    color: var(--kb-ink);
    font-size: 1.25rem;
}
.kb-registration-poster span {
    display: block;
    margin-top: 28px;
    color: var(--kb-ink-muted);
    font-size: 0.85rem;
    font-weight: 700;
}

/* ============================================================================
   Form filas
   ============================================================================ */
.kb-form-row { display: flex; flex-direction: column; gap: 20px; max-width: 480px; margin-bottom: 24px; }
.kb-form-row--horizontal { flex-direction: row; align-items: end; max-width: 100%; flex-wrap: wrap; }
.kb-form-error { color: #B23B3B; background: #FDEDED; padding: 12px 16px; border-radius: var(--kb-radius-sm); margin-bottom: 16px; }
.kb-form-success { color: var(--kb-sage); background: #ECF3EF; padding: 12px 16px; border-radius: var(--kb-radius-sm); margin-bottom: 16px; }
.kb-danger-zone {
    border-color: #E5B8B8;
    background: #FFF8F8;
}
.kb-danger-zone h2 { color: #8F2D2D; }

/* ============================================================================
   Modal
   ============================================================================ */
.kb-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(28, 27, 24, 0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.kb-modal {
    background: var(--kb-bg-card);
    border-radius: var(--kb-radius-lg);
    padding: 32px;
    max-width: 420px;
    width: calc(100% - 32px);
    box-shadow: var(--kb-shadow-lg);
}
.kb-modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ============================================================================
   Login page
   ============================================================================ */
.kb-login {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.kb-login-card {
    background: var(--kb-bg-card);
    border-radius: var(--kb-radius-lg);
    padding: 48px 40px;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--kb-shadow-lg);
}
.kb-login-card h1 { text-align: center; margin-bottom: 8px; }
.kb-login-brand { text-align: center; margin-bottom: 32px; }
.kb-login-brand .kb-brand-logo { margin: 0 auto 12px; }

/* ============================================================================
   Public join page
   ============================================================================ */
.kb-join {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.kb-join-card {
    width: 100%;
    max-width: 430px;
    background: var(--kb-bg-card);
    border: 1px solid var(--kb-sand-100);
    border-radius: var(--kb-radius-lg);
    padding: 32px 24px;
    box-shadow: var(--kb-shadow-lg);
}
.kb-join-brand {
    margin-bottom: 12px;
    color: var(--kb-blush);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.kb-join-logo {
    display: block;
    max-width: 180px;
    max-height: 64px;
    object-fit: contain;
}
.kb-public-links { display: flex; gap: 16px; margin: 0 0 20px; font-weight: 700; }
.kb-join-card h1 { font-size: 2rem; }
.kb-join-card .kb-form-row { max-width: none; }
.kb-join-birthday {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--kb-sand-100);
}

.kb-segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.kb-choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--kb-sand-100);
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
    cursor: pointer;
}

.kb-choice input {
    width: auto;
    margin: 0;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 768px) {
    .kb-app { flex-direction: column; }
    .kb-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 16px; gap: 4px; }
    .kb-sidebar h1 { width: 100%; margin-bottom: 8px; font-size: 1.25rem; }
    .kb-sidebar-section { width: 100%; margin: 12px 12px 0; font-size: 0.63rem; }
    .kb-sidebar a { padding: 8px 12px; font-size: 0.9rem; }
    .kb-sidebar .kb-signout { margin-top: 0; }
    .kb-main { padding: 20px 16px; }
    .kb-card-value { font-size: 2rem; }
    h1 { font-size: 1.85rem; }
    .kb-help-registration-layout { grid-template-columns: 1fr; }
    .kb-help-qr { max-width: 220px; }
    .kb-registration-poster-inner { padding: 28px 20px; }
}

@media print {
    body:has(.kb-registration-poster) {
        background: #fff;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    body:has(.kb-registration-poster) .kb-sidebar,
    body:has(.kb-registration-poster) .kb-help-header,
    body:has(.kb-registration-poster) .kb-help-registration,
    body:has(.kb-registration-poster) .kb-help-grid,
    body:has(.kb-registration-poster) .kb-help-common {
        display: none !important;
    }
    body:has(.kb-registration-poster) .kb-app,
    body:has(.kb-registration-poster) .kb-main {
        display: block;
        min-height: auto;
        max-width: none;
        padding: 0;
    }
    body:has(.kb-registration-poster) .kb-registration-poster {
        min-height: 100vh;
        margin: 0;
        align-items: center;
        page-break-inside: avoid;
    }
    body:has(.kb-registration-poster) .kb-registration-poster-inner {
        width: 7in;
        min-height: 9.3in;
        display: flex;
        flex-direction: column;
        justify-content: center;
        box-shadow: none;
    }
    body:has(.kb-registration-poster) .kb-registration-poster img {
        width: 2.6in;
        height: 2.6in;
        margin: 0 auto;
    }
}
