/* =========================================================
   JPERsecurity — estilos base (mobile-first)
   ========================================================= */

:root {
    --color-primary: #0d6efd;
    --color-primary-dark: #0a4fb5;
    --color-accent: #e8590c;
    --color-bg: #f7f9fc;
    --color-surface: #ffffff;
    --color-text: #1c2733;
    --color-text-muted: #5b6b7c;
    --color-border: #e3e8ef;
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.12);
    --radius: 14px;
    --header-height: 64px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

h1, h2, h3 {
    line-height: 1.25;
    margin: 0 0 0.5em;
}

p {
    margin: 0 0 1em;
}

img, svg {
    max-width: 100%;
    display: block;
}

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    padding: 0.6em 1.2em;
    border-radius: 999px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
}

.btn-outline:hover {
    background: rgba(13, 110, 253, 0.08);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    color: var(--color-text);
}

.btn-block {
    width: 100%;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    height: var(--header-height);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    height: 100%;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--color-text);
}

.brand-logo {
    height: 44px;
    width: auto;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-actions .btn {
    padding: 0.55em 1em;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ---------- Modal de login ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 32, 0.55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 0;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    position: relative;
    background: var(--color-surface);
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 28px 24px calc(24px + env(safe-area-inset-bottom, 0px));
    box-shadow: var(--shadow-md);
    animation: slideUp 0.2s ease-out;
}

.modal-lg {
    max-width: 760px;
}

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

.modal-subtitle {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 8px;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

#loginForm label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 8px;
}

#loginForm input {
    padding: 0.7em 0.9em;
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s ease;
}

#loginForm input:focus {
    border-color: var(--color-primary);
}

.form-message {
    min-height: 1.2em;
    font-size: 0.85rem;
    color: #d92d20;
    margin: 8px 0 4px;
}

.form-message.success {
    color: #12793f;
}

#loginSubmit {
    margin-top: 12px;
}

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    padding: 48px 16px;
}

.hero-inner {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.hero h1 {
    font-size: 1.6rem;
    font-weight: 800;
}

.hero p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
}

.hero .btn-primary {
    background: #fff;
    color: var(--color-primary-dark);
}

.hero .btn-primary:hover {
    background: #eef2ff;
}

/* ---------- Servicios ---------- */
.services {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 16px 56px;
    text-align: center;
}

.services h2 {
    font-size: 1.4rem;
    font-weight: 800;
}

.section-subtitle {
    color: var(--color-text-muted);
    max-width: 480px;
    margin: 0 auto 28px;
}

.services-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    text-align: left;
}

.service-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.service-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.service-photo {
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    background: var(--color-border);
}

.service-body {
    padding: 18px 20px 20px;
}

.service-card h3 {
    font-size: 1.05rem;
}

.service-card p {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    margin-bottom: 0;
}

/* ---------- Página secundaria (cotizaciones) ---------- */
.page-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 32px 16px;
}

.page-header-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.page-header-with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.header-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.back-link {
    display: inline-block;
    color: var(--color-primary);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.back-link:hover {
    text-decoration: underline;
}

/* ---------- Listado de cotizaciones ---------- */
.list-row {
    cursor: pointer;
    transition: background 0.1s ease;
}

.list-row:hover {
    background: var(--color-bg);
}

.status-badge {
    display: inline-block;
    padding: 0.3em 0.8em;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-no-enviado {
    background: #e0ecff;
    color: #0a4fb5;
}

.status-enviado {
    background: #d6f5df;
    color: #12793f;
}

.status-bloqueado {
    background: #fde2e2;
    color: #b42318;
    margin-left: 6px;
}

.acciones-cell {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

/* ---------- Mantenimiento de productos ---------- */
.paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.tabs-selector {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.preview-warning {
    background: #fff7e6;
}

.detail-summary table th {
    width: 140px;
    white-space: nowrap;
}

/* ---------- Envío de cotización ---------- */
.checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    font-size: 0.92rem;
}

.checkbox-field input {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.checkbox-field input:disabled + span {
    color: var(--color-text-muted);
}

#btnGenerarPdf {
    margin-top: 18px;
}

.pdf-resultado {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.quotes-section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 16px 56px;
}

.quotes-section-inner {
    max-width: 1100px;
}

.quotes-section h2 {
    font-size: 1.25rem;
}

.quotes-section .section-subtitle {
    margin: 0 0 20px;
}

.form-fields-narrow {
    max-width: 480px;
}

/* ---------- Formularios de la app (reutilizable) ---------- */
.app-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-field label {
    font-size: 0.85rem;
    font-weight: 600;
}

.form-field input,
.form-field select {
    padding: 0.7em 0.9em;
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s ease;
}

.form-field input:focus,
.form-field select:focus {
    border-color: var(--color-primary);
}

.totals-table {
    min-width: 0;
}

.totals-table td {
    font-weight: 700;
    font-size: 1rem;
}

.range-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--color-border);
    padding: 0;
    border: none;
    cursor: pointer;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.25);
    cursor: pointer;
}

.range-input::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.25);
    cursor: pointer;
}

.range-input::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: var(--color-border);
}

.app-form .btn {
    align-self: flex-start;
    margin-top: 4px;
}

/* ---------- Tabla de ítems de cotización ---------- */
.category-block {
    margin-bottom: 24px;
}

.category-label {
    font-size: 1rem;
    margin-bottom: 10px;
}

.items-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.items-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.items-table th,
.items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    white-space: nowrap;
}

.items-table th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.items-table tbody tr:last-child td {
    border-bottom: none;
}

.cell-input {
    width: 100px;
    padding: 0.4em 0.6em;
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
}

.cell-input:focus {
    border-color: var(--color-primary);
}

.subtotal-cell {
    font-weight: 600;
}

#btnAgregarItem {
    margin-top: 16px;
}

.btn-sm {
    padding: 0.35em 0.9em;
    font-size: 0.8rem;
}

/* ---------- Footer ---------- */
.site-footer {
    background: #10202f;
    color: #cbd5e1;
    padding: 32px 16px 0;
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 24px;
}

.footer-brand strong {
    color: #fff;
    font-size: 1.1rem;
}

.footer-contact p {
    margin: 0 0 6px;
    font-size: 0.9rem;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    padding: 14px 16px;
    font-size: 0.8rem;
    color: #8394a5;
}

/* =========================================================
   Breakpoints — tablet y escritorio
   ========================================================= */
@media (min-width: 600px) {
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero h1 {
        font-size: 2rem;
    }
}

@media (min-width: 900px) {
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .hero {
        padding: 72px 16px;
    }

    .hero h1 {
        font-size: 2.4rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    .footer-inner {
        flex-direction: row;
        justify-content: space-between;
    }

    .modal-overlay {
        align-items: center;
    }

    .modal {
        border-radius: 20px;
    }
}
