/* ===================================================
   SIMULADOR DE TAXAS — Global Stylesheet
   =================================================== */

/* --- Variables --- */
:root {
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --primary-light:  #dbeafe;
    --success:        #16a34a;
    --success-light:  #dcfce7;
    --danger:         #dc2626;
    --danger-light:   #fee2e2;
    --warning:        #d97706;
    --warning-light:  #fef3c7;
    --bg:             #f1f5f9;
    --surface:        #ffffff;
    --border:         #e2e8f0;
    --text:           #1e293b;
    --muted:          #64748b;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow:         0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg:      0 10px 25px -3px rgba(0,0,0,.12), 0 4px 6px -2px rgba(0,0,0,.06);
    --radius:         10px;
    --radius-sm:      6px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}
a { color: var(--primary); }
code { font-family: monospace; background: var(--bg); padding: .1em .35em; border-radius: 3px; font-size: .875em; }

/* --- Layout --- */
.container    { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.page-content { padding: 1.5rem 0; }

/* ===================================================
   LOGIN PAGE
   =================================================== */
.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #60a5fa 100%);
}
.login-card {
    background: var(--surface);
    border-radius: 18px;
    padding: 2.75rem 2.25rem 2.25rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.login-icon {
    width: 62px;
    height: 62px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: var(--primary);
}
.login-brand h1 { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.login-brand p  { color: var(--muted); font-size: .875rem; margin-top: .25rem; }

/* ===================================================
   FORM ELEMENTS
   =================================================== */
.field { margin-bottom: 1.125rem; }
.field label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .375rem;
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select {
    width: 100%;
    padding: .625rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    appearance: none;
}
input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
input::placeholder { color: #94a3b8; }

/* Input with prefix/suffix addon */
.input-addon {
    display: flex;
    align-items: stretch;
}
.input-addon input {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
    flex: 1;
}
.input-addon-prefix .addon-txt {
    display: flex;
    align-items: center;
    padding: .625rem .75rem;
    background: #f8fafc;
    border: 1.5px solid var(--border);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    font-size: .875rem;
    color: var(--muted);
    white-space: nowrap;
    line-height: 1;
}
.input-addon-suffix input {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: none;
    border-left: 1.5px solid var(--border);
}
.input-addon-suffix .addon-txt {
    display: flex;
    align-items: center;
    padding: .625rem .75rem;
    background: #f8fafc;
    border: 1.5px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: .875rem;
    color: var(--muted);
    white-space: nowrap;
    line-height: 1;
}

/* Password eye toggle */
.input-pw-wrap { position: relative; }
.input-pw-wrap input { padding-right: 2.75rem; }
.btn-eye {
    position: absolute;
    right: .625rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: .25rem;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: color .15s;
}
.btn-eye:hover { color: var(--text); }

/* ===================================================
   BUTTONS
   =================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .5625rem 1.125rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}
.btn:hover       { opacity: .9; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active      { transform: translateY(0); box-shadow: none; }
.btn-primary     { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success     { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger      { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-outline     { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost       { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-block       { width: 100%; padding: .8rem; font-size: 1rem; }
.btn-sm          { padding: .375rem .625rem; font-size: .8125rem; }

/* ===================================================
   NAVBAR
   =================================================== */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.navbar-brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    font-weight: 700;
    font-size: 1.0625rem;
    color: var(--text);
    text-decoration: none;
    flex: 1;
}
.navbar-brand .nav-icon { color: var(--primary); display: flex; }
.navbar-badge {
    font-size: .6875rem;
    font-weight: 500;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .125rem .5rem;
    margin-left: .25rem;
}
.navbar-actions { display: flex; align-items: center; gap: .5rem; }

/* ===================================================
   TABS
   =================================================== */
.tab-list {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}
.tab-btn {
    padding: .75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: .9375rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: .375rem;
}
.tab-btn:hover        { color: var(--text); }
.tab-btn.active       { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel            { display: none; }
.tab-panel.active     { display: block; }

/* ===================================================
   CARDS
   =================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.375rem;
    box-shadow: var(--shadow-sm);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.125rem;
}
.card-title { font-size: 1rem; font-weight: 700; }

/* ===================================================
   BRAND GRID (Admin)
   =================================================== */
.brand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
}
.brand-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .15s;
}
.brand-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.brand-card-name  { font-size: 1.0625rem; font-weight: 800; color: var(--text); margin-bottom: .75rem; }
.brand-card-fees  { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1rem; }
.fee-badge {
    background: var(--primary-light);
    color: var(--primary);
    font-size: .7rem;
    font-weight: 700;
    padding: .15rem .5rem;
    border-radius: 999px;
    white-space: nowrap;
}
.brand-card-actions { display: flex; gap: .375rem; flex-wrap: wrap; }

/* ===================================================
   SECTION HEADER
   =================================================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.125rem;
}
.section-title { font-size: 1.0625rem; font-weight: 700; }

/* ===================================================
   ALERTS
   =================================================== */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 1.125rem;
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}
.alert-success { background: var(--success-light); color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fde68a; }

/* ===================================================
   MODAL
   =================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}
.modal-backdrop.hidden { display: none; }
.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 620px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}
.modal-header h2 { font-size: 1.125rem; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: .25rem .4rem;
    border-radius: 4px;
    transition: all .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body   { padding: 1.5rem; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: var(--surface);
}

/* ===================================================
   FEES FORM GRID (inside modal)
   =================================================== */
.fees-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .875rem;
    margin-top: .75rem;
}
.fees-grid .field { margin-bottom: 0; }
.fees-grid .field label { font-size: .8rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ===================================================
   SETTINGS PAGE
   =================================================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

/* ===================================================
   EMPTY STATE
   =================================================== */
.empty-state {
    text-align: center;
    padding: 3.5rem 1rem;
    color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .45; }
.empty-state p     { font-size: .9375rem; margin-bottom: .375rem; font-weight: 500; }
.empty-state small { font-size: .8125rem; }

/* ===================================================
   SIMULATOR
   =================================================== */
.sim-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.625rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.sim-panel h2 { font-size: 1.0625rem; font-weight: 700; margin-bottom: 1.125rem; }

/* Mode toggle */
.mode-toggle {
    display: flex;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .25rem;
    gap: .25rem;
    margin-bottom: 1.375rem;
}
.mode-btn {
    flex: 1;
    padding: .5rem .75rem;
    border: none;
    background: none;
    border-radius: 4px;
    font-size: .875rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s;
    text-align: center;
    line-height: 1.4;
}
.mode-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

/* Sim fields */
.sim-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
    align-items: end;
}

/* ===================================================
   RESULTS
   =================================================== */
.results-section { margin-top: .5rem; }
.results-header  {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    margin-bottom: .875rem;
    flex-wrap: wrap;
}
.results-header h3    { font-size: 1rem; font-weight: 700; }
.results-sub          { font-size: .8125rem; color: var(--muted); }

.min-notice {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .8125rem;
    color: var(--success);
    font-weight: 500;
    padding: .5rem .875rem;
    background: var(--success-light);
    border-radius: var(--radius-sm);
    margin-bottom: .875rem;
    border: 1px solid #bbf7d0;
}

.result-list { display: flex; flex-direction: column; gap: .5rem; }

/* Staggered entry animation */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result-item {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: box-shadow .15s;
    animation: fadeSlideIn .2s ease-out both;
}
.result-item:hover          { box-shadow: var(--shadow-sm); }
.result-item.item-highlight { border-color: var(--success); background: #f0fdf4; }
.result-item.item-dim       { opacity: .5; }

.result-row {
    display: flex;
    align-items: center;
    padding: .9rem 1rem;
    cursor: pointer;
    user-select: none;
    gap: .625rem;
}
.result-label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--muted);
    min-width: 125px;
    flex-shrink: 0;
}
.result-main {
    flex: 1;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text);
}
.result-installment {
    font-size: .8rem;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}
.margin-ok-badge {
    font-size: .7rem;
    background: var(--success-light);
    color: var(--success);
    padding: .1rem .45rem;
    border-radius: 999px;
    font-weight: 700;
    vertical-align: middle;
    margin-left: .375rem;
}
.result-chevron {
    color: var(--muted);
    display: flex;
    transition: transform .2s;
    flex-shrink: 0;
}
.result-chevron.open { transform: rotate(180deg); }

.result-detail {
    display: none;
    padding: .875rem 1rem;
    background: #f8fafc;
    border-top: 1px solid var(--border);
}
.result-detail.open { display: block; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
}
.detail-item strong {
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin-bottom: .2rem;
    font-weight: 600;
}
.detail-item span {
    font-size: .9375rem;
    font-weight: 700;
    color: var(--text);
}
.detail-item span.green { color: var(--success); }
.detail-item span.blue  { color: var(--primary); }

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 768px) {
    .navbar        { padding: 0 1rem; }
    .container     { padding: 0 1rem; }
    .page-content  { padding: 1rem 0; }
    .brand-grid    { grid-template-columns: 1fr; }
    .fees-grid     { grid-template-columns: repeat(2, 1fr); }
    .detail-grid   { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
    .sim-fields    { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .login-card       { padding: 1.75rem 1.25rem; }
    .fees-grid        { grid-template-columns: 1fr 1fr; }
    .detail-grid      { grid-template-columns: 1fr 1fr; }
    .result-label     { min-width: 95px; }
    .result-main      { font-size: .9375rem; }
    .modal-box        { max-height: 95vh; }
    .mode-btn         { font-size: .8125rem; padding: .4rem .5rem; }
}
