@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* ============================================
   RESET Y BASE
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Fuentes */
    --font-main: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    
    /* Colores modo claro */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --surface: #ffffff;
    --surface-hover: #f8f9fa;
    
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-tertiary: #adb5bd;
    
    --border-color: #dee2e6;
    --border-light: #e9ecef;
    
    --brand-primary: #1b6f5f;
    --brand-hover: #145447;
    --brand-light: #e6f4f1;
    
    --success: #28a745;
    --error: #dc3545;
    --error-bg: #f8d7da;
    --error-border: #f5c6cb;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --transition: 0.2s ease;
}

/* Modo oscuro */
body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --surface: #2d2d2d;
    --surface-hover: #3a3a3a;
    
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --text-tertiary: #6c757d;
    
    --border-color: #495057;
    --border-light: #3a3a3a;
    
    --brand-primary: #5bd6b2;
    --brand-hover: #3bbf99;
    --brand-light: #1f4038;
    
    --error-bg: #4a2528;
    --error-border: #6a3235;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition), color var(--transition);
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.theme-toggle {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon-light,
.theme-icon-dark {
    font-size: 1.25rem;
    position: absolute;
    transition: opacity var(--transition), transform var(--transition);
}

.theme-icon-light {
    color: #ffa500;
}

.theme-icon-dark {
    color: #4a90e2;
}

/* Estado inicial (modo claro) */
body:not(.dark-mode) .theme-icon-light {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body:not(.dark-mode) .theme-icon-dark {
    opacity: 0;
    transform: rotate(180deg) scale(0.5);
}

/* Estado modo oscuro */
body.dark-mode .theme-icon-light {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
}

body.dark-mode .theme-icon-dark {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    padding: 2rem 1.5rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* ============================================
   SEARCH SECTION
   ============================================ */
.search-section {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    border: 1px solid var(--border-light);
    transition: all var(--transition);
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 1.125rem;
    pointer-events: none;
}

#searchInput {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition);
    font-family: var(--font-main);
}

#searchInput::placeholder {
    color: var(--text-tertiary);
}

#searchInput:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-light);
}

.btn-search {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--brand-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-main);
}

.btn-search:hover:not(:disabled) {
    background-color: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-search:active:not(:disabled) {
    transform: translateY(0);
}

.btn-search:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading {
    display: none;
}

.btn-loading.visible {
    display: inline-flex;
}

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   ERROR MESSAGE
   ============================================ */
.error-message {
    background-color: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error-border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    margin-top: 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-message::before {
    content: "\f33a";
    font-family: "bootstrap-icons";
    font-size: 1.125rem;
}

/* ============================================
   RESULTS
   ============================================ */
.results-container {
    margin-top: 2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.results-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--surface);
    font-size: 0.9375rem;
}

.results-table thead {
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
}

.results-table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.results-table td {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color var(--transition);
}

.results-table tbody tr:hover {
    background-color: var(--surface-hover);
}

.results-table td:active {
    background-color: var(--bg-tertiary);
}

.results-hint {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

/* Badge de origen */
.badge-origen {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-sifen {
    background-color: rgba(59, 130, 246, 0.15);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-local {
    background-color: rgba(16, 185, 129, 0.15);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

body.dark-mode .badge-sifen {
    background-color: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

body.dark-mode .badge-local {
    background-color: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

/* ============================================
   INFO SECTION
   ============================================ */
.info-section {
    margin-top: 2rem;
}

.info-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: all var(--transition);
}

.info-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-title i {
    color: var(--brand-primary);
    font-size: 1.375rem;
}

.info-text {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.info-text:last-child {
    margin-bottom: 0;
}

.info-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border-light);
    padding: 1.5rem;
    margin-top: auto;
    transition: background-color var(--transition);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-content p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================
   PROMO BANNER - FACTURACIÓN ELECTRÓNICA
   ============================================ */
.promo-section {
    margin-top: 2rem;
}

.promo-card {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition);
}

.promo-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.promo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(30, 58, 138, 0.3);
}

.promo-badge {
    display: inline-block;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1f2937;
    padding: 0.375rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.promo-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin: 0.5rem auto 1rem;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.promo-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    margin: 1rem 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.promo-title-accent {
    color: #fbbf24;
    display: inline-block;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.promo-description {
    color: #e5e7eb;
    font-size: 0.9375rem;
    line-height: 1.6;
    margin: 1.25rem auto;
    max-width: 500px;
    opacity: 0.95;
}

.promo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    background: linear-gradient(135deg, #25d366 0%, #20bd5a 100%);
    color: white;
    padding: 0.875rem 2rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: 1rem;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    transition: all var(--transition);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.promo-btn:hover {
    background: linear-gradient(135deg, #20bd5a 0%, #1da851 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
}

.promo-btn:active {
    transform: translateY(0);
}

.promo-btn i {
    font-size: 1.375rem;
}

/* Modo oscuro - Mantener identidad visual pero ajustar detalles */
body.dark-mode .promo-card {
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

body.dark-mode .promo-card:hover {
    box-shadow: 0 15px 40px rgba(30, 58, 138, 0.5);
}

body.dark-mode .promo-description {
    color: #f3f4f6;
    opacity: 1;
}

/* ============================================
   FLOATING BUTTONS
   ============================================ */
.whatsapp-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background-color: #25d366;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    z-index: 90;
    transition: all var(--transition);
    text-decoration: none;
}

.whatsapp-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(37, 211, 102, 0.4);
}

.whatsapp-btn:active {
    transform: scale(0.95);
}

.whatsapp-btn i {
    color: white;
    font-size: 1.75rem;
}

.scroll-to-top {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    background-color: var(--brand-primary);
    border: none;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    z-index: 90;
    transition: all var(--transition);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background-color: var(--brand-hover);
    transform: translateY(-3px);
}

.scroll-to-top i {
    color: white;
    font-size: 1.25rem;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--success);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 500;
    z-index: 200;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast i {
    font-size: 1.25rem;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablets */
@media (min-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }
    
    .logo {
        width: 48px;
        height: 48px;
    }
    
    .search-section {
        padding: 2.5rem;
    }
    
    .search-form {
        flex-direction: row;
        align-items: stretch;
    }
    
    .input-wrapper {
        flex: 1;
    }
    
    .btn-search {
        width: auto;
        min-width: 140px;
    }
    
    .info-card {
        padding: 2.5rem;
    }
    
    /* Promo Banner - Tablet */
    .promo-card {
        padding: 3rem 2.5rem;
    }
    
    .promo-logo {
        width: 70px;
        height: 70px;
    }
    
    .promo-title {
        font-size: 2.125rem;
    }
    
    .promo-description {
        font-size: 1rem;
        max-width: 600px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .main-content {
        padding: 3rem 1.5rem;
    }
    
    .container {
        max-width: 900px;
    }
    
    .search-section {
        padding: 3rem;
    }
    
    .info-card {
        padding: 3rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .info-title {
        font-size: 1.5rem;
    }
    
    .info-text {
        font-size: 1.0625rem;
    }
    
    /* Promo Banner - Desktop */
    .promo-card {
        padding: 3.5rem 3rem;
    }
    
    .promo-logo {
        width: 80px;
        height: 80px;
    }
    
    .promo-title {
        font-size: 2.5rem;
    }
    
    .promo-description {
        font-size: 1.0625rem;
    }
    
    .promo-btn {
        font-size: 1.0625rem;
        padding: 1rem 2.5rem;
    }
}

/* ============================================
   CDC RESULT CARDS
   ============================================ */
.cdc-card {
    background-color: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition), border-color var(--transition);
}

.cdc-section-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cdc-section-title i {
    font-size: 1rem;
}

.cdc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .cdc-grid {
        grid-template-columns: 1fr 1fr;
    }
    .cdc-grid .cdc-card {
        margin-bottom: 0;
    }
}

.cdc-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.cdc-row:last-child {
    margin-bottom: 0;
}

@media (min-width: 480px) {
    .cdc-row {
        grid-template-columns: 1fr 1fr;
    }
}

.cdc-pair {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0;
}

.cdc-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.cdc-value {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 600;
    word-break: break-word;
}

.cdc-value.cdc-copy {
    cursor: pointer;
    padding: 0.375rem 0.5rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition), border-color var(--transition);
}

.cdc-value.cdc-copy:hover {
    background-color: var(--bg-secondary);
    border-color: var(--brand-primary);
}

.cdc-totales {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .cdc-totales {
        grid-template-columns: repeat(4, 1fr);
    }
}

.cdc-total-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cdc-total-main {
    color: var(--success);
    font-size: 1.125rem;
    font-weight: 700;
}

.results-table th.num,
.results-table td.num {
    text-align: right;
}

.results-table tbody tr:hover {
    background-color: var(--surface-hover);
    cursor: default;
}

.results-table td {
    cursor: default;
}

/* Estado header del resultado segun cancelacion / no encontrado */
.results-count.badge-ok {
    background-color: rgba(16, 185, 129, 0.15);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.results-count.badge-cancelled {
    background-color: rgba(220, 38, 38, 0.15);
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

body.dark-mode .results-count.badge-ok {
    background-color: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

body.dark-mode .results-count.badge-cancelled {
    background-color: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
}

/* Animaciones reducidas para usuarios que lo prefieran */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
