:root {
    --bg: #f5f5f4;
    --surface: #ffffff;

    --text: #18181b;
    --muted: #71717a;

    --primary: #18181b;
    --primary-hover: #27272a;

    --danger: #dc2626;
    --success: #15803d;

    --border: #e4e4e7;

    --radius: 16px;
}


/* =========================
   BASE
========================= */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--bg);
    color: var(--text);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(24, 24, 27, 0.18);
    outline-offset: 2px;
}


/* =========================
   TOP BAR
========================= */

.topbar {
    height: 72px;

    background: var(--surface);

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;

    padding: 0 24px;

    border-bottom: 1px solid var(--border);

    position: sticky;
    top: 0;

    z-index: 20;
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
}

.subtitle {
    color: var(--muted);
    font-size: 13px;
}

.top-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    border: 1px solid var(--border);
    background: white;

    padding: 10px 14px;

    border-radius: 10px;

    font-weight: 600;

    transition:
        background 0.1s ease,
        transform 0.08s ease;
}

.icon-btn:hover {
    background: #f4f4f5;
}

.icon-btn:active {
    transform: scale(0.97);
}


/* =========================
   LAYOUT PRINCIPAL
========================= */

.pos-layout {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        380px;

    gap: 20px;

    padding: 20px;

    max-width: 1500px;

    margin: auto;
}

.products-section,
.cart-section {
    background: var(--surface);

    border-radius: var(--radius);

    border: 1px solid var(--border);
}


/* =========================
   PRODUCTOS
========================= */

.products-section {
    padding: 20px;
}

.section-title h2,
.cart-header h2 {
    margin: 0;
}

.section-title p {
    margin: 4px 0 20px;

    color: var(--muted);
}

.products-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fill, minmax(150px, 1fr));

    gap: 14px;
}

.product-button {
    min-height: 105px;

    border: 1px solid rgba(0, 0, 0, 0.10);

    border-radius: 14px;

    padding: 18px 12px;

    display: flex;
    flex-direction: column;
    justify-content: center;

    gap: 8px;

    position: relative;
    overflow: hidden;

    transition:
        transform 0.08s ease,
        filter 0.08s ease,
        box-shadow 0.08s ease;
}

.product-button:hover {
    filter: brightness(0.98);

    box-shadow:
        0 4px 12px
        rgba(0, 0, 0, 0.05);
}

.product-button:active {
    transform: scale(0.96);
}

.product-button::after {
    content: "";

    position: absolute;
    inset: 0;

    background:
        rgba(255, 255, 255, 0.12);

    pointer-events: none;
}

.product-button > * {
    position: relative;

    z-index: 1;
}

.product-name {
    font-size: 17px;

    color: #000;

    font-weight: 700;

    line-height: 1.2;
}

.product-price {
    font-size: 15px;

    color: #000;

    font-weight: 700;
}


/* =========================
   CUENTA
========================= */

.cart-section {
    display: flex;
    flex-direction: column;

    min-height:
        calc(100vh - 112px);

    position: sticky;

    top: 92px;
}

.cart-header {
    padding: 20px;

    display: flex;

    justify-content: space-between;
    align-items: flex-start;

    gap: 16px;

    border-bottom:
        1px solid var(--border);
}

.cart-header span {
    color: var(--muted);

    font-size: 13px;
}

.text-danger {
    border: 0;

    background: transparent;

    color: var(--danger);

    font-weight: 600;
}

.cart-items {
    padding: 10px 20px;

    flex: 1;

    overflow-y: auto;

    overscroll-behavior: contain;
}

.cart-item {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        auto;

    gap: 12px;

    padding: 14px 0;

    border-bottom:
        1px solid var(--border);
}

.cart-item-name {
    font-weight: 600;
}

.cart-item-price {
    color: var(--muted);

    font-size: 13px;

    margin-top: 3px;
}

.quantity-control {
    display: flex;
    align-items: center;

    gap: 10px;

    margin-top: 8px;
}

.qty-button {
    width: 34px;
    height: 34px;

    border-radius: 9px;

    border:
        1px solid var(--border);

    background: white;

    font-size: 18px;

    font-weight: 700;
}

.qty-button:active {
    transform: scale(0.94);
}

.item-subtotal {
    font-weight: 700;

    white-space: nowrap;
}

.cart-footer {
    padding: 20px;

    border-top:
        1px solid var(--border);

    background: white;

    border-radius:
        0 0 var(--radius) var(--radius);
}

.total-row {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 16px;

    margin-bottom: 16px;
}

.total-row span {
    font-size: 18px;

    font-weight: 600;
}

.total-row strong {
    font-size: 32px;

    white-space: nowrap;
}


/* =========================
   BOTONES
========================= */

.btn-primary {
    border: 0;

    background: var(--primary);

    color: white;

    border-radius: 12px;

    padding: 14px 20px;

    font-weight: 700;

    transition:
        background 0.1s ease,
        transform 0.08s ease;
}

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

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

.btn-primary:disabled {
    opacity: 0.35;

    cursor: not-allowed;

    transform: none;
}

.btn-charge {
    width: 100%;

    min-height: 58px;

    font-size: 19px;
}

.btn-large {
    width: 100%;

    min-height: 56px;

    font-size: 18px;
}

.btn-small {
    border: 0;

    background: var(--primary);

    color: white;

    padding: 10px 14px;

    border-radius: 10px;

    font-weight: 700;

    white-space: nowrap;
}

.btn-secondary {
    border:
        1px solid var(--border);

    background: white;

    border-radius: 12px;

    padding: 14px;

    font-weight: 600;
}


/* =========================
   EMPTY STATE
========================= */

.empty-state {
    text-align: center;

    padding: 60px 20px;

    color: var(--muted);
}

.empty-icon {
    font-size: 42px;
}


/* =========================
   MODALES GENERALES
========================= */

.modal {
    position: fixed;

    inset: 0;

    z-index: 100;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;
}

.hidden {
    display: none !important;
}

.modal-overlay {
    position: absolute;

    inset: 0;

    background:
        rgba(0, 0, 0, 0.48);

    backdrop-filter: blur(2px);
}

.modal-card {
    position: relative;

    background: white;

    border-radius: 20px;

    width: 100%;
    max-width: 500px;

    max-height: 92vh;

    overflow-y: auto;

    padding: 26px;

    z-index: 2;

    box-shadow:
        0 24px 60px
        rgba(0, 0, 0, 0.20);
}

.modal-close {
    position: absolute;

    top: 14px;
    right: 14px;

    border: 0;

    background: #f4f4f5;

    width: 36px;
    height: 36px;

    border-radius: 50%;

    font-size: 22px;

    line-height: 1;

    z-index: 20;
}


/* =========================
   MODAL COBRO
========================= */

.payment-card {
    max-width: 500px;
}

.payment-total {
    margin: 24px 0;

    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 16px;
}

.payment-total strong {
    font-size: 36px;

    white-space: nowrap;
}

.field-label {
    display: block;

    margin-bottom: 8px;

    font-weight: 600;
}

.money-input {
    display: flex;
    align-items: center;

    border:
        2px solid var(--border);

    border-radius: 14px;

    padding: 8px 14px;

    font-size: 24px;
}

.money-input:focus-within {
    border-color: var(--text);
}

.money-input input {
    width: 100%;

    border: 0;
    outline: 0;

    padding: 8px;

    font-size: 28px;

    min-width: 0;
}

.quick-payments {
    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 8px;

    margin: 14px 0 20px;
}

.quick-btn {
    padding: 12px 8px;

    border-radius: 10px;

    border:
        1px solid var(--border);

    background: white;

    font-weight: 600;
}

.quick-btn:active {
    transform: scale(0.97);
}

.change-box {
    padding: 18px;

    border-radius: 14px;

    margin-bottom: 16px;

    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 16px;

    background: #f4f4f5;
}

.change-box strong {
    font-size: 28px;

    white-space: nowrap;
}

.change-box.success {
    background: #dcfce7;

    color: var(--success);
}

.change-box.warning {
    background: #fee2e2;

    color: var(--danger);
}


/* =========================
   MODAL PRODUCTOS
========================= */

.products-modal {
    width: 100%;

    max-width: 560px;

    height: min(80vh, 650px);

    max-height: 80vh;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    padding: 0;
}

.products-modal .modal-title-row {
    flex-shrink: 0;

    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 12px;

    padding:
        20px
        58px
        16px
        20px;

    margin: 0;

    background: white;

    border-bottom:
        1px solid var(--border);

    position: sticky;

    top: 0;

    z-index: 8;
}

.products-modal .modal-title-row h2 {
    margin: 0;

    font-size: 21px;
}

.products-modal .modal-close {
    top: 12px;
    right: 12px;

    z-index: 15;
}


/* Lista desplazable */

.products-admin-list {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    overscroll-behavior: contain;

    padding: 0 20px;

    scrollbar-width: thin;
}

.products-admin-list::-webkit-scrollbar {
    width: 7px;
}

.products-admin-list::-webkit-scrollbar-track {
    background: transparent;
}

.products-admin-list::-webkit-scrollbar-thumb {
    background: #d4d4d8;

    border-radius: 20px;
}

.product-admin-item {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;

    padding: 10px 0;

    border-bottom:
        1px solid var(--border);
}

.product-admin-item > div {
    min-width: 0;
}

.product-admin-item strong {
    display: inline-block;

    max-width: 100%;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-admin-item small {
    color: var(--muted);
}

.product-admin-item button {
    flex-shrink: 0;

    border:
        1px solid var(--border);

    background: white;

    padding: 8px 12px;

    border-radius: 9px;

    font-weight: 600;
}


/* Formulario de producto */

.products-modal .product-form {
    flex-shrink: 0;

    display: grid;

    gap: 14px;

    max-height: 55vh;

    overflow-y: auto;

    padding:
        18px 20px 20px;

    background: white;

    border-top:
        1px solid var(--border);

    overscroll-behavior: contain;
}

.product-form label {
    display: grid;

    gap: 6px;

    font-weight: 600;
}

.product-form input {
    width: 100%;

    border:
        1px solid var(--border);

    padding: 12px;

    border-radius: 10px;

    background: white;
}


/* Color picker */

.product-form input[type="color"] {
    width: 100%;
    height: 52px;

    padding: 5px;

    cursor: pointer;
}

.product-form input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.product-form input[type="color"]::-webkit-color-swatch {
    border: 0;

    border-radius: 8px;
}


/* Checkbox */

.checkbox-row {
    display: flex !important;

    align-items: center;

    gap: 10px;
}

.checkbox-row input {
    width: 18px;
    height: 18px;

    padding: 0;
}


/* Acciones formulario */

.form-actions {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 10px;

    position: sticky;

    bottom: 0;

    background: white;

    padding-top: 4px;
}


/* =========================
   HISTORIAL
========================= */

.history-modal {
    max-width: 560px;
}

.history-list {
    margin-top: 12px;
}

.history-item {
    padding: 16px 0;

    border-bottom:
        1px solid var(--border);
}

.history-header {
    display: flex;

    justify-content: space-between;

    gap: 16px;

    margin-bottom: 8px;
}

.history-total {
    font-weight: 800;

    font-size: 18px;

    white-space: nowrap;
}

.history-products {
    color: var(--muted);

    font-size: 14px;

    line-height: 1.45;
}


/* =========================
   SUCCESS
========================= */

.success-card {
    text-align: center;

    max-width: 420px;
}

.success-icon {
    margin: auto;

    width: 60px;
    height: 60px;

    border-radius: 50%;

    background: #dcfce7;

    color: var(--success);

    display: flex;

    align-items: center;
    justify-content: center;

    font-size: 30px;

    font-weight: 700;
}

.success-card strong {
    display: block;

    font-size: 32px;

    margin-bottom: 20px;
}

.success-change {
    color: var(--success);
}


/* =========================
   TABLET
========================= */

@media (max-width: 900px) {

    .pos-layout {
        grid-template-columns: 1fr;
    }

    .cart-section {
        min-height: auto;

        position: relative;

        top: 0;
    }

    .cart-footer {
        position: sticky;

        bottom: 0;

        z-index: 10;

        box-shadow:
            0 -5px 20px
            rgba(0, 0, 0, 0.06);
    }

}


/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {

    .topbar {
        padding:
            0 10px;

        height: 62px;

        gap: 8px;
    }

    .topbar h1 {
        font-size: 18px;
    }

    .subtitle {
        font-size: 12px;
    }

    .top-actions {
        gap: 6px;
    }

    .icon-btn {
        padding:
            8px 9px;

        font-size: 12px;
    }

    .pos-layout {
        padding: 10px;

        gap: 10px;
    }

    .products-section {
        padding: 14px;
    }

    .section-title p {
        margin-bottom: 14px;
    }

    .products-grid {
        grid-template-columns:
            repeat(2, 1fr);

        gap: 9px;
    }

    .product-button {
        min-height: 90px;

        padding: 12px 8px;
    }

    .product-name {
        font-size: 15px;
    }

    .product-price {
        font-size: 14px;
    }

    .cart-section {
        border-radius: 14px;
    }

    .cart-header {
        padding: 16px;
    }

    .cart-items {
        padding:
            8px 16px;
    }

    .cart-footer {
        padding: 16px;
    }

    .total-row strong {
        font-size: 28px;
    }

    .modal {
        padding: 10px;

        align-items: flex-end;
    }

    .modal-card {
        border-radius:
            20px 20px 10px 10px;

        max-height: 90vh;
    }

    .payment-total strong {
        font-size: 32px;
    }

    .quick-payments {
        grid-template-columns:
            repeat(2, 1fr);
    }

    .change-box strong {
        font-size: 24px;
    }


    /* Productos mobile */

    .products-modal {
        height: 82vh;

        max-height: 82vh;

        border-radius:
            20px 20px 10px 10px;
    }

    .products-modal .modal-title-row {
        padding:
            16px
            54px
            12px
            16px;
    }

    .products-modal .modal-title-row h2 {
        font-size: 19px;
    }

    .products-admin-list {
        padding:
            0 16px;
    }

    .product-admin-item {
        padding: 9px 0;
    }

    .products-modal .product-form {
        max-height: 58vh;

        padding:
            14px
            16px
            18px;
    }

    .form-actions {
        gap: 8px;
    }

}


/* =========================
   MÓVIL MUY PEQUEÑO
========================= */

@media (max-width: 380px) {

    .topbar h1 {
        font-size: 16px;
    }

    .icon-btn {
        font-size: 11px;

        padding:
            7px 7px;
    }

    .products-grid {
        gap: 7px;
    }

    .product-button {
        min-height: 82px;
    }

    .product-name {
        font-size: 14px;
    }

    .product-price {
        font-size: 13px;
    }

}