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

:root {
    --primary: #1e3a8a; /* Deep blue used in many Gov/Corporate docs */
    --primary-light: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --dark: #1f2937;
    --border: #e5e7eb;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Layout Structure */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    background: var(--primary);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    z-index: 10;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 80px; /* Space for bottom nav */
}

/* View State Management */
.view-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
    max-width: 800px;
    margin: 0 auto;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards & Containers */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
    position: relative;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f9fafb;
    transition: all 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; gap: 0; }
}

/* Switches & Radios */
.switch-container {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.radio-card {
    flex: 1;
    position: relative;
}

.radio-card input {
    position: absolute;
    opacity: 0;
}

.radio-card label {
    display: block;
    padding: 0.75rem;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.radio-card input:checked + label {
    border-color: var(--primary);
    background: rgba(30, 58, 138, 0.05);
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover { background: #1e40af; box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }




/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    gap: 4px;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-item i { font-size: 1.25rem; }

.nav-item.active { color: var(--primary); }

#nav-new-retention       { color: var(--success); }
#nav-new-retention:hover { color: #059669; }

#nav-config       { color: var(--primary); }
#nav-config:hover { color: #1e40af; }

/* Results specific */
.result-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.result-row.total {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    border-top: 1px solid #cbd5e1;
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

/* History List */
.retention-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.retention-item:last-child { border-bottom: none; }

.retention-info h4 { font-size: 1rem; margin-bottom: 2px; }
.retention-info p { font-size: 0.8rem; color: var(--text-secondary); }

.retention-action {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-light);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.2s;
}
.retention-action:hover { background: rgba(59, 130, 246, 0.2); }

/* Utilities */
.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* Login PIN Pad */
.pin-view {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary), var(--dark));
    color: white;
    z-index: 9999;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
}

.pin-view.active {
    display: flex;
}

.pin-header {
    text-align: center;
    margin-bottom: 2rem;
}

.pin-header h2 { font-size: 1.5rem; letter-spacing: 1px; }

.pin-display {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.pin-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    transition: all 0.2s;
}

.pin-dot.filled {
    background: white;
    border-color: white;
    transform: scale(1.2);
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 2rem;
}

.pin-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 1.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.2s;
}

.pin-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pin-btn:active {
    background: white;
    color: var(--primary);
    transform: scale(0.95);
}

.pin-btn.action {
    background: transparent;
    border: none;
    font-size: 1.2rem;
}

/* =============================================================
   FORMULARIO: EMITIR COMPROBANTE
   ============================================================= */

.form-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.875rem;
}

.form-section-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.form-section-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.icon-blue  { background: rgba(30, 58, 138, 0.1);  color: var(--primary); }
.icon-green { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.icon-amber { background: rgba(245, 158, 11, 0.12); color: #d97706; }

.form-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.2;
}

.form-section-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ---------- Toggle 75% / 100% ---------- */
.pct-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 0.375rem;
}

.pct-toggle input[type="radio"] {
    display: none;
}

.pct-toggle label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 0.5rem;
    cursor: pointer;
    background: #f9fafb;
    transition: background 0.2s, color 0.2s;
    user-select: none;
}

.pct-toggle label:first-of-type {
    border-right: 1px solid var(--border);
}

.pct-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1;
    transition: color 0.2s;
}

.pct-desc {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    transition: color 0.2s;
}

.pct-toggle input:checked + label {
    background: var(--primary);
}

.pct-toggle input:checked + label .pct-num,
.pct-toggle input:checked + label .pct-desc {
    color: white;
}

/* ---------- Badge de moneda ---------- */
.currency-tag {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #6b7280;
    background: #e5e7eb;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 5px;
    vertical-align: middle;
}

/* ---------- Caja de resultados ---------- */
.calc-box {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    border-radius: 12px;
    padding: 1.125rem 1.25rem;
    margin-top: 1rem;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
}

.calc-label {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.72);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.calc-val {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    font-variant-numeric: tabular-nums;
}

.calc-separator {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 0.5rem 0;
}

.calc-highlight .calc-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

.calc-highlight .calc-val {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fbbf24;
}

/* ---------- Botón Generar ---------- */
.btn-generate {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1.0625rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s;
    font-family: inherit;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.38);
    margin-bottom: 1rem;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(16, 185, 129, 0.5);
}

.btn-generate:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-generate i {
    font-size: 1.125rem;
}

/* ---------- Fix form-row en móvil (gap mínimo) ---------- */
@media (max-width: 600px) {
    .form-card { padding: 1rem; }
    .form-row  { gap: 0.625rem; }
}

