/* ── Design Tokens ── */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: rgba(79, 70, 229, 0.08);
    --accent: #06b6d4;
    --danger: #ef4444;
    --success: #22c55e;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 1rem;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 4px 24px rgba(0,0,0,.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.12);
    --gradient-hero: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface-alt);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Hero Header ── */
.hero-header {
    background: var(--gradient-hero);
    color: #fff;
    padding: 2.5rem 0 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 48px;
    background: var(--surface-alt);
    clip-path: ellipse(55% 100% at 50% 100%);
}
.hero-header h1 {
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -0.5px;
    margin-bottom: .35rem;
}
.hero-header p {
    opacity: .85;
    font-size: .95rem;
    margin: 0;
}
/* ── Primary Logo ── */
.primary-logo-wrapper {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    animation: float 3s ease-in-out infinite;
}
.primary-logo {
    height: 100px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 24px rgba(255,255,255,.35));
    transition: transform .3s ease;
}
.primary-logo:hover {
    transform: scale(1.05);
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ── Logo Marquee Slider ── */
.logo-marquee-section {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    padding: .5rem 0;
    z-index: 5;
    margin-bottom: 1rem;
}
.logo-marquee-section::before,
.logo-marquee-section::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 80px;
    z-index: 2;
    pointer-events: none;
}
.logo-marquee-section::before {
    left: 0;
    background: linear-gradient(90deg, var(--surface) 0%, transparent 100%);
}
.logo-marquee-section::after {
    right: 0;
    background: linear-gradient(270deg, var(--surface) 0%, transparent 100%);
}
.logo-marquee-track {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    width: max-content;
    animation: marqueeScroll 20s linear infinite;
}
.logo-marquee-track:hover {
    animation-play-state: paused;
}
.logo-marquee-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .2rem .4rem;
    border-radius: .75rem;
    transition: transform .3s ease, filter .3s ease;
}
.logo-marquee-item img {
    height: 42px;
    width: auto;
    max-width: 130px;
    object-fit: contain;
    filter: grayscale(40%) opacity(.7);
    transition: filter .3s ease, transform .3s ease;
}
.logo-marquee-item:hover img {
    filter: grayscale(0%) opacity(1);
    transform: scale(1.12);
}
@keyframes marqueeScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ── Cards ── */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .3s ease, transform .3s ease;
    overflow: hidden;
}
.form-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.form-card .card-header {
    background: var(--primary-soft);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: .6rem;
}
.form-card .card-header i {
    font-size: 1.25rem;
}
.form-card .card-body {
    padding: 1.5rem 1.25rem;
}

/* ── Form Controls ── */
.form-label {
    font-weight: 600;
    font-size: .85rem;
    color: var(--text);
    margin-bottom: .35rem;
}
.form-control, .form-select {
    border-radius: .625rem;
    border: 1.5px solid var(--border);
    padding: .6rem .85rem;
    font-size: .9rem;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Radio Group ── */
.radio-group {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}
.radio-group .form-check {
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: .625rem;
    padding: .55rem 1rem .55rem 2.2rem;
    transition: border-color .2s, background .2s;
    cursor: pointer;
    margin: 0;
}
.radio-group .form-check:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.radio-group .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ── Signature Canvas ── */
.signature-wrapper {
    position: relative;
}
#signatureCanvas,
#techSignatureCanvas {
    width: 100%;
    max-width: 480px;
    height: 180px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: crosshair;
    touch-action: none;
    transition: border-color .25s;
}
#signatureCanvas:hover,
#signatureCanvas.drawing,
#techSignatureCanvas:hover,
#techSignatureCanvas.drawing {
    border-color: var(--primary);
}
.signature-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    color: var(--text-muted);
    font-size: .85rem;
    opacity: .6;
    transition: opacity .3s;
}
#signatureCanvas.has-drawing ~ .signature-hint {
    opacity: 0;
}

/* ── Buttons ── */
.btn-primary-custom {
    background: var(--gradient-hero);
    border: none;
    color: #fff;
    font-weight: 700;
    padding: .75rem 2rem;
    border-radius: .75rem;
    font-size: 1rem;
    letter-spacing: .3px;
    box-shadow: 0 4px 16px rgba(79, 70, 229, .35);
    transition: transform .2s, box-shadow .2s, opacity .2s;
}
.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(79, 70, 229, .45);
    color: #fff;
    opacity: .92;
}
.btn-primary-custom:active {
    transform: translateY(0);
}
.btn-clear-sig {
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 600;
    font-size: .82rem;
    border-radius: .625rem;
    padding: .4rem .85rem;
    transition: border-color .2s, color .2s;
}
.btn-clear-sig:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ── Records Section ── */
.records-section {
    margin-top: 3rem;
}
.records-section .section-title {
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.records-section .section-title .badge {
    background: var(--primary);
    font-size: .7rem;
    padding: .35rem .65rem;
    border-radius: 2rem;
}

/* ── Table ── */
.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.table-wrapper table {
    margin-bottom: 0;
}
.table-wrapper thead {
    background: var(--primary-soft);
}
.table-wrapper thead th {
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--primary);
    border-bottom: 2px solid var(--border);
    padding: .85rem 1rem;
    white-space: nowrap;
}
.table-wrapper tbody td {
    padding: .75rem 1rem;
    font-size: .88rem;
    vertical-align: middle;
    border-color: var(--border);
}
.table-wrapper tbody tr {
    transition: background .15s;
}
.table-wrapper tbody tr:hover {
    background: var(--primary-soft);
}
.ticket-badge {
    display: inline-block;
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    color: #fff;
    font-weight: 700;
    font-size: .78rem;
    padding: .25rem .65rem;
    border-radius: .5rem;
    letter-spacing: .3px;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 3rem;
    opacity: .35;
    display: block;
    margin-bottom: .75rem;
}

/* ── Delete Button ── */
.btn-delete-record,
.btn-view-record {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    border-radius: .5rem;
    padding: .3rem .55rem;
    font-size: .85rem;
    transition: border-color .2s, color .2s, background .2s;
    cursor: pointer;
}
.btn-delete-record:hover {
    border-color: var(--danger);
    color: #fff;
    background: var(--danger);
}
.btn-view-record:hover {
    border-color: var(--primary);
    color: #fff;
    background: var(--primary);
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
}

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 2rem 0 1.5rem;
    color: var(--text-muted);
    font-size: .82rem;
}

/* ═══════ RECEIPT MODAL ═══════ */
.receipt-modal-content {
    border: none;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.receipt-modal-header {
    background: var(--gradient-hero);
    color: #fff;
    border: none;
    padding: 1rem 1.5rem;
}
.receipt-modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
.receipt-modal-footer {
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    gap: .75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Receipt Paper ── */
.receipt-paper {
    background: #fff;
    padding: 0;
    font-size: .88rem;
    color: var(--text);
    /* Force to 1 page maximum */
    max-height: 290mm;
    overflow: hidden;
}
.receipt-header-band {
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    color: #fff;
}
.receipt-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}
.receipt-header-info h2 {
    font-weight: 800;
    font-size: 1.2rem;
    margin: 0 0 .25rem 0;
    letter-spacing: .5px;
}
.receipt-ticket {
    display: inline-block;
    background: rgba(255,255,255,.2);
    backdrop-filter: blur(6px);
    padding: .2rem .75rem;
    border-radius: .5rem;
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: .5px;
}
.receipt-meta {
    padding: .5rem 2rem;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 600;
}
.receipt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.receipt-grid .receipt-section:first-child {
    border-right: 1px solid var(--border);
}
.receipt-section {
    padding: .6rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.receipt-section h6 {
    font-weight: 700;
    font-size: .82rem;
    color: var(--primary);
    margin-bottom: .6rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.receipt-section h6 i {
    font-size: 1rem;
}
.receipt-full {
    grid-column: 1 / -1;
}
.receipt-table {
    width: 100%;
    border-collapse: collapse;
}
.receipt-table td {
    padding: .3rem 0;
    vertical-align: top;
    font-size: .84rem;
}
.receipt-table td:first-child {
    font-weight: 600;
    color: var(--text-muted);
    width: 35%;
    padding-right: .75rem;
}
.receipt-table td:last-child {
    color: var(--text);
}
.receipt-complaint {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: .5rem;
    padding: .5rem 1rem;
    margin: 0;
    font-size: .84rem;
    min-height: 40px;
    white-space: pre-wrap;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.receipt-sig-section {
    padding-bottom: 1.5rem;
}
.receipt-sig-box {
    border: 2px dashed var(--border);
    border-radius: .75rem;
    padding: .5rem;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-alt);
}
.receipt-sig-box img {
    max-height: 80px;
    max-width: 200px;
    object-fit: contain;
}

/* ── Action Buttons ── */
.btn-action-receipt {
    border: none;
    border-radius: .625rem;
    padding: .6rem 1.4rem;
    font-weight: 700;
    font-size: .88rem;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    transition: transform .2s, box-shadow .2s, opacity .2s;
    cursor: pointer;
    color: #fff;
}
.btn-action-receipt:hover {
    transform: translateY(-2px);
    color: #fff;
    opacity: .92;
}
.btn-action-receipt:active {
    transform: translateY(0);
}
.btn-print {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    box-shadow: 0 4px 14px rgba(71, 85, 105, .35);
}
.btn-pdf {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 14px rgba(220, 38, 38, .35);
}
.btn-whatsapp {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 4px 14px rgba(34, 197, 94, .35);
}

/* ── Animations ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}
.anim-in {
    animation: fadeInUp .5s ease forwards;
}
.anim-in:nth-child(2) { animation-delay: .08s; }
.anim-in:nth-child(3) { animation-delay: .16s; }
.anim-in:nth-child(4) { animation-delay: .24s; }

/* ── Print Styles ── */
@media print {
    body * { visibility: hidden; }
    #receiptContent, #receiptContent * { visibility: visible; }
    #receiptContent {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    .receipt-header-band {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .hero-header, .logo-marquee-section, .records-section,
    .site-footer, .btn-primary-custom, .btn-clear-sig,
    .modal-header, .modal-footer { display: none !important; }
}

/* ── Responsive ── */
@media (max-width: 576px) {
    .hero-header h1 { font-size: 1.5rem; }
    #signatureCanvas, #techSignatureCanvas { height: 140px; }
    .receipt-grid { grid-template-columns: 1fr; }
    .receipt-grid .receipt-section:first-child { border-right: none; }
    .receipt-header-band { flex-direction: column; text-align: center; padding: 1rem; }
    .receipt-logo { height: 45px; }
    .receipt-header-info h2 { font-size: 1rem; }
    .btn-action-receipt { padding: .5rem 1rem; font-size: .8rem; }
}
