/* =================================================================================
   SMART OPTICAL POS - PREMIUM INTELLIGENCE UI
   ================================================================================= */

/* --- GENERAL CARD STRUCTURE --- */
.pos-card-mostrador-premium {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.92) 100%);
    border-radius: 18px;
    padding: 20px;
    box-shadow:
        0 14px 34px -22px rgba(2, 6, 23, 0.48),
        0 6px 14px -10px rgba(2, 6, 23, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.35);
    /* removed backdrop-filter */
    -webkit-/* removed backdrop-filter */
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    overflow: hidden;
    position: relative;
    /* Border-left is set inline for specific cards */
}

.pos-card-mostrador-premium::before {
    content: '';
    position: absolute;
    inset: -1px;
    background:
        radial-gradient(700px 240px at 14% -10%, rgba(59, 130, 246, 0.14) 0%, rgba(59, 130, 246, 0) 62%),
        radial-gradient(700px 240px at 88% 110%, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0) 60%);
    background:
        radial-gradient(700px 240px at 14% -10%, color-mix(in srgb, var(--primary) 18%, transparent) 0%, transparent 62%),
        radial-gradient(700px 240px at 88% 110%, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0) 60%);
    opacity: 0.95;
    pointer-events: none;
}

.pos-card-mostrador-premium:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.28);
    border-color: color-mix(in srgb, var(--primary) 28%, rgba(148, 163, 184, 0.35));
    box-shadow:
        0 18px 40px -24px rgba(2, 6, 23, 0.55),
        0 8px 18px -12px rgba(2, 6, 23, 0.26),
        inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

#card-trabajo.pos-card-mostrador-premium {
    overflow: visible;
    padding-top: 58px;
}

#card-trabajo.pos-card-mostrador-premium .pos-header-premium {
    position: absolute;
    top: 12px;
    right: 12px;
    margin-bottom: 0 !important;
    z-index: 6;
}

#card-trabajo.pos-card-mostrador-premium .pos-header-premium>div {
    justify-content: flex-end;
}

/* --- HEADER PREMIUM --- */
.pos-header-premium {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pos-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-box-premium {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.icon-amber {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    color: #d97706;
}

.icon-emerald {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: #059669;
}

.header-text h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.2;
}

.header-text span {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

/* --- SMART INVOICE CONTAINER --- */
.invoice-smart-container {
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #e2e8f0;
    margin-bottom: 24px;
}

.invoice-badge {
    display: flex;
    flex-direction: column;
    position: relative;
}

.invoice-badge-corner {
    position: absolute;
    top: 12px;
    left: 12px;
    right: auto;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(148, 163, 184, 0.38);
    border-radius: 999px;
    padding: 9px 14px;
    /* removed backdrop-filter */
    -webkit-/* removed backdrop-filter */
    box-shadow:
        0 12px 24px -18px rgba(2, 6, 23, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
    z-index: 6;
    pointer-events: none;
    white-space: nowrap;
}

.invoice-badge-corner .invoice-label {
    margin-bottom: 0;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.invoice-badge-corner .invoice-hash {
    font-weight: 900;
    color: rgba(100, 116, 139, 0.75);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    line-height: 1;
}

.invoice-badge-corner .invoice-input {
    min-width: 6ch;
    width: auto;
    max-width: 15ch;
    font-size: 1.08rem;
    font-weight: 900;
    letter-spacing: 0.35px;
    text-align: left;
    color: #0f172a;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    outline: none !important;
}

.invoice-badge-corner .status-dot {
    display: none;
}

.invoice-badge-inline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 6px 10px;
}

.invoice-badge-inline .invoice-label {
    margin-bottom: 0;
}

.invoice-badge-inline .invoice-input {
    width: 72px;
    font-size: 1rem;
    letter-spacing: 1px;
}

.invoice-badge-inline .status-dot {
    position: static;
    margin-left: 2px;
}

.invoice-label {
    font-size: 0.65rem;
    color: #64748b;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.invoice-input {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    font-weight: 800;
    color: #0f172a;
    width: 140px;
    padding: 0;
    outline: none;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.5px;
}

.invoice-input[readonly] {
    cursor: default;
    caret-color: transparent;
    pointer-events: none;
    user-select: none;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    position: absolute;
    top: 2px;
    right: -10px;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.btn-smart-action {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
    box-shadow: 0 10px 22px -20px rgba(2, 6, 23, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.btn-smart-action:hover {
    background: rgba(248, 250, 252, 0.95);
    color: #334155;
    border-color: rgba(59, 130, 246, 0.28);
    border-color: color-mix(in srgb, var(--primary) 28%, rgba(148, 163, 184, 0.35));
    transform: translateY(-1px);
    box-shadow: 0 14px 26px -20px rgba(2, 6, 23, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

/* --- CLIENT SECTION --- */
.section-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.section-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
    display: block;
}

.btn-link-action {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-link-action:hover {
    background: rgba(239, 246, 255, 0.9);
}

.btn-link-action span {
    font-size: 1rem;
}

/* Inputs with Icons */
.input-with-icon {
    position: relative;
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: rgba(100, 116, 139, 0.85);
    pointer-events: none;
}

.input-premium-smart {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    font-size: 0.9rem;
    color: #1e293b;
    font-weight: 550;
    outline: none;
    box-shadow:
        0 10px 22px -22px rgba(2, 6, 23, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-premium-smart:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    border-color: var(--primary);
    background: #fff;
}

.client-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

/* --- FINANCE SECTION (SMART COLLAPSIBLE) --- */
.finance-smart-section {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.92) 0%, rgba(255, 255, 255, 0.9) 100%);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 16px;
    padding: 16px;
    margin-top: 24px;
    transition: all 0.3s ease;
    box-shadow:
        0 14px 30px -26px rgba(2, 6, 23, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
    position: relative;
    overflow: hidden;
}

.finance-smart-section::before {
    content: '';
    position: absolute;
    inset: -1px;
    background:
        radial-gradient(680px 240px at 0% -10%, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0) 60%);
    background:
        radial-gradient(680px 240px at 0% -10%, color-mix(in srgb, var(--primary) 14%, transparent) 0%, transparent 60%);
    opacity: 0.9;
    pointer-events: none;
}

.finance-smart-section:focus-within {
    border-color: rgba(59, 130, 246, 0.28);
    border-color: color-mix(in srgb, var(--primary) 28%, rgba(148, 163, 184, 0.35));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(248, 250, 252, 0.92) 100%);
}

.finance-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.finance-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-finance {
    color: #64748b;
    font-size: 1.4rem;
}

.finance-text {
    display: flex;
    flex-direction: column;
}

.finance-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
}

.finance-subtitle {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* --- SMART SWITCH --- */
.switch-smart {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch-smart input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-smart {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(226, 232, 240, 0.95);
    box-shadow: inset 0 1px 1px rgba(2, 6, 23, 0.08);
    transition: .3s;
    border-radius: 34px;
}

.slider-smart:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.switch-smart input:checked+.slider-smart {
    background-color: var(--primary);
    background-image: linear-gradient(135deg, var(--primary), rgba(99, 102, 241, 0.9));
}

.switch-smart input:checked+.slider-smart:before {
    transform: translateX(20px);
}

/* --- FINANCE DETAILS (EXPANDED) --- */
.finance-details-panel {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #cbd5e1;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.total-work-input-container label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 4px;
    font-weight: 600;
}

.currency-input-wrapper {
    position: relative;
}

.currency-symbol {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: #dc2626;
    font-size: 1rem;
}

.input-total-work {
    width: 100%;
    padding: 10px 12px 10px 30px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #dc2626;
    border: 2px solid #fecaca;
    background: #fff;
    border-radius: 8px;
    outline: none;
}

.input-total-work:focus {
    border-color: #ef4444;
}

.balance-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.balance-amount {
    font-weight: 800;
    color: #dc2626;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.pending {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #ffedd5;
}

.btn-mini-link {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-mini-link:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* --- MODE SELECTOR (NEW) --- */
.mode-toggle-group {
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    display: flex;
    gap: 4px;
}

.mode-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    color: #64748b;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.mode-option:hover {
    color: #334155;
}

.mode-option.active#mode-opt-factura {
    background: white;
    color: #2563eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-color: #e2e8f0;
}

.mode-option.active#mode-opt-mostrador {
    background: white;
    color: #10b981;
    /* Emerald */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-color: #e2e8f0;
}

.mode-option span.material-symbols-outlined {
    font-size: 1.2rem;
}

/* --- BTN ICON SMART (QUICK ADD) --- */
.btn-icon-smart {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0ea5e9;
    color: white;
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.2);
    transition: transform 0.2s;
}

.btn-icon-smart:hover {
    transform: translateY(-2px);
    background: #0284c7;
}

/* =========================================================
   MATERIAL DESIGN 3 — VENTAS MODULE
   ========================================================= */

/* Panel derecho: crece para igualar altura del izquierdo */
#sales-panel-right {
    display: flex !important;
    flex-direction: column !important;
}

/* Carrito: ocupa el espacio restante cuando está visible */
#contenedor-productos-venta {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    border-radius: 14px !important;
    margin-top: 4px !important;
}

#contenedor-productos-venta[style*="none"] {
    display: none !important;
}

/* Tabla del carrito: scroll interno */
#tabla-productos-venta {
    flex: 1;
}

/* Placeholder carrito vacío */
#cart-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 32px 16px;
    color: #cbd5e1;
    text-align: center;
    min-height: 160px;
    border: 1.5px dashed #e2e8f0;
    border-radius: 14px;
    margin-top: 8px;
    background: #fafbfc;
}

#cart-empty-state .material-symbols-outlined {
    font-size: 2.8rem;
    opacity: 0.5;
}

#cart-empty-state p {
    font-size: 0.88rem;
    font-weight: 700;
    margin: 0;
    color: #94a3b8;
}

#cart-empty-state span {
    font-size: 0.73rem;
    color: #cbd5e1;
    font-weight: 500;
}

/* Ocultar placeholder cuando el carrito tiene productos */
#sales-panel-right:has(#contenedor-productos-venta:not([style*="none"])) #cart-empty-state {
    display: none !important;
}

/* Section labels → MD3: acento de color primario */
.section-label {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    color: var(--primary) !important;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-label::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 13px;
    background: var(--primary);
    border-radius: 2px;
    flex-shrink: 0;
}

/* Section divider: línea suave MD3 */
.section-label-row {
    padding-bottom: 10px !important;
    margin-bottom: 12px !important;
    border-bottom: 1px solid #f1f5f9;
}

/* Header del panel de productos: MD3 */
.pos-header-label {
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    color: #1e293b;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--primary);
    opacity: 0.95;
}

/* Inputs MD3 Outlined: foco limpio sin glow */
.input-premium-smart:focus {
    border-color: var(--primary) !important;
    border-width: 2px !important;
    box-shadow: none !important;
}

.pos-input:focus {
    border-color: var(--primary) !important;
    box-shadow: none !important;
}

/* Botón guardar apertura: MD3 pill */
#btn-apertura-caja-guardar {
    border-radius: 100px !important;
    font-size: 0.78rem !important;
    padding: 0 16px !important;
    height: 38px !important;
}

/* Botón agregar al carrito: MD3 tonal */
#btn-add-canasta {
    border-radius: 14px !important;
    box-shadow: 0 2px 8px rgba(16,185,129,0.25) !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}

#btn-add-canasta:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 16px rgba(16,185,129,0.35) !important;
}

/* Card apertura de caja: borde top primario */
#box-apertura-caja-ventas {
    border-top: 3px solid var(--primary) !important;
}

/* ===================================================
   APERTURA DE CAJA: CHIP COLLAPSE ANIMATION
   =================================================== */

/* Transiciones base */
#box-apertura-caja-ventas {
    transition:
        max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        border-radius 0.45s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.4s ease,
        background 0.4s ease,
        transform 0.25s ease,
        box-shadow 0.25s ease !important;
    overflow: hidden !important;
    max-height: 400px;
    will-change: max-height, border-radius, padding;
}

/* Estado chip (colapsado) */
#box-apertura-caja-ventas.caja-mini {
    max-height: 52px !important;
    padding: 7px 14px !important;
    border-radius: 100px !important;
    cursor: pointer !important;
    animation: cajaChipBounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#box-apertura-caja-ventas.caja-mini:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 18px rgba(22, 163, 74, 0.25) !important;
}

/* Shimmer sobre el chip */
#box-apertura-caja-ventas.caja-mini::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 55%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.38), transparent);
    animation: cajaShimmer 2.8s ease-in-out infinite 0.7s;
    pointer-events: none;
}

@keyframes cajaChipBounce {
    0%   { transform: scaleX(0.96) scaleY(1.06); }
    40%  { transform: scaleX(1.03) scaleY(0.96); }
    70%  { transform: scaleX(0.99) scaleY(1.01); }
    100% { transform: scale(1); }
}

@keyframes cajaShimmer {
    0%   { left: -80%;  opacity: 0; }
    15%  { opacity: 1; }
    50%  { left: 130%;  opacity: 0; }
    100% { left: 130%;  opacity: 0; }
}

/* Ocultar controles cuando colapsado */
#box-apertura-caja-ventas.caja-mini #apertura-caja-controls,
#box-apertura-caja-ventas.caja-mini #btn-apertura-sin-base,
#box-apertura-caja-ventas.caja-mini #apertura-caja-resumen,
#box-apertura-caja-ventas.caja-mini #apertura-caja-bg-effect,
#box-apertura-caja-ventas.caja-mini .apertura-caja-titles {
    display: none !important;
}

/* Mini-info: visible solo cuando chip */
#apertura-caja-mini-info {
    display: none;
    flex: 1;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    margin: 0 4px;
}

#box-apertura-caja-ventas.caja-mini #apertura-caja-mini-info {
    display: flex !important;
}

/* Main row sin wrap */
#apertura-caja-main-row {
    flex-wrap: nowrap !important;
}

/* Botón toggle collapse */
#btn-toggle-apertura-caja {
    background: none !important;
    border: none !important;
    cursor: pointer;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: inherit;
    opacity: 0.5;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
}

#btn-toggle-apertura-caja:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08) !important;
    transform: scale(1.15);
}

/* Ripple al colapsar */
.caja-ripple-burst {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(22, 163, 74, 0.5);
    top: 50%;
    left: 22px;
    transform: translate(-50%, -50%) scale(0);
    animation: cajaRippleBurst 0.65s ease-out forwards;
    pointer-events: none;
    z-index: 99;
}

@keyframes cajaRippleBurst {
    0%   { transform: translate(-50%, -50%) scale(0);  opacity: 0.75; }
    100% { transform: translate(-50%, -50%) scale(6);  opacity: 0; }
}
