/* =========================================
   PALETA DE COLORES "LIA NAILS" (UXINTACE)
   ========================================= */
:root {
    --col-peach: #FFBB94;
    --col-salmon: #FB9590;
    --col-rose: #DC586D;
    --col-berry: #A33757;
    --col-plum: #852E4E;
    --col-dark: #4C1D3D;
    --bg-page: #FFF5F2; 
    --bg-white: #ffffff;
    --text-main: #4C1D3D; 
    --text-light: #852E4E;
    --success: #2ecc71; 
    --warning: #F39C12;
    --danger: #DC586D; 
}

/* =========================================
   ESTILOS GENERALES
   ========================================= */
body { 
    font-family: 'Segoe UI', 'Roboto', sans-serif; 
    background: var(--bg-page) linear-gradient(180deg, #fff0ea 0%, #ffe0d5 100%) fixed;
    color: var(--text-main); 
    line-height: 1.6;
    padding: 20px; 
    margin: 0;
}

.container { 
    max-width: 1000px; 
    margin: 0 auto 30px auto; 
    background: var(--bg-white); 
    padding: 30px; 
    border-radius: 20px; 
    box-shadow: 0 10px 25px rgba(76, 29, 61, 0.08); 
    border: 1px solid rgba(255, 187, 148, 0.3);
    /* Asegura que el contenedor nunca sea más ancho que la pantalla */
    box-sizing: border-box; 
    width: 100%;
}

h2 { 
    color: var(--col-berry); 
    margin-top: 0; 
    border-bottom: 2px solid var(--col-peach); 
    padding-bottom: 15px; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-size: 1.5rem;
}

h2 i { color: var(--col-rose); }

/* =========================================
   FORMULARIOS E INPUTS
   ========================================= */
.input-group { 
    display: flex; 
    flex-wrap: wrap; 
    align-items: flex-end; 
    gap: 15px; 
    background: linear-gradient(to right, #fff9f6, #fff); 
    padding: 20px; 
    border-radius: 15px; 
    margin-bottom: 25px; 
    border: 1px solid var(--col-peach);
}

.field { flex: 1; min-width: 150px; }
.field-large { flex: 2; min-width: 200px; }

.field label { 
    display: block; 
    font-size: 0.85rem; 
    font-weight: 700; 
    margin-bottom: 6px; 
    color: var(--col-plum); 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field input, 
.field select { 
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid #e0e0e0; 
    border-radius: 8px; 
    box-sizing: border-box; 
    font-size: 0.95rem;
    color: var(--col-dark);
    background: var(--bg-white);
    transition: all 0.3s ease;
}

.field input:focus, 
.field select:focus {
    outline: none;
    border-color: var(--col-rose);
    box-shadow: 0 0 0 3px rgba(220, 88, 109, 0.15);
}

/* =========================================
   BOTONES
   ========================================= */
button { 
    cursor: pointer; 
    padding: 10px 18px; 
    border-radius: 8px; 
    border: none; 
    font-weight: 600; 
    font-size: 0.9rem; 
    transition: all 0.3s ease; 
    letter-spacing: 0.3px;
}

.btn-save { 
    background: linear-gradient(45deg, var(--col-berry), var(--col-plum)); 
    color: var(--bg-white); 
    min-width: 120px; 
    box-shadow: 0 4px 10px rgba(133, 46, 78, 0.3);
}

.btn-save:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 6px 15px rgba(133, 46, 78, 0.4);
}

.btn-cancel { 
    background: #f1f1f1; 
    color: var(--col-plum); 
    display: none; 
    margin-right: 10px; 
}
.btn-cancel:hover { background: #e0e0e0; }

.btn-icon { 
    background: none; 
    border: none; 
    font-size: 1.1rem; 
    color: #aaa; 
    cursor: pointer; 
    padding: 5px 8px; 
    border-radius: 4px; 
}
.btn-icon:hover { color: var(--col-berry); background: #fff0f5; }
.btn-delete:hover { color: var(--col-rose); background: #fff0f0; }

/* =========================================
   TABLAS
   ========================================= */
table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0 10px; 
    margin-top: 10px; 
}

th { 
    text-align: left; 
    color: var(--col-plum); 
    font-size: 0.8rem; 
    text-transform: uppercase; 
    padding: 0 15px; 
    font-weight: 700;
    letter-spacing: 0.5px;
}

td { 
    background: var(--bg-white); 
    padding: 15px; 
    border-top: 1px solid #f0f0f0; 
    border-bottom: 1px solid #f0f0f0; 
    vertical-align: middle; 
    color: var(--col-dark);
}

tr td:first-child { 
    border-left: 1px solid #f0f0f0; 
    border-top-left-radius: 12px; 
    border-bottom-left-radius: 12px; 
}
tr td:last-child { 
    border-right: 1px solid #f0f0f0; 
    border-top-right-radius: 12px; 
    border-bottom-right-radius: 12px; 
}
tbody tr:hover td {
    background-color: #fff9f6;
    border-color: var(--col-peach);
}

/* =========================================
   COMPONENTES
   ========================================= */
.cost-per-use { 
    color: var(--col-berry); 
    font-weight: bold; 
    font-size: 0.9rem; 
    background: #fdf2f4; 
    padding: 4px 10px; 
    border-radius: 20px; 
    display: inline-block; 
    margin-top: 2px; 
    border: 1px solid rgba(220, 88, 109, 0.1);
}

.stock-wrapper { display: flex; align-items: center; gap: 8px; }
.btn-stock { 
    width: 28px; height: 28px; 
    border-radius: 50%; 
    border: 1px solid var(--col-peach); 
    background: var(--bg-white); 
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; 
    color: var(--col-plum);
    transition: 0.2s;
}
.btn-stock:hover { background: var(--col-peach); color: var(--bg-white); }
.stock-display { font-weight: bold; font-size: 1.2rem; color: var(--col-dark); min-width: 25px; text-align: center; }

.bar-container { 
    background: #f0f0f0; 
    height: 8px; 
    border-radius: 10px; 
    width: 100%; 
    position: relative; 
    overflow: hidden; 
    margin-bottom: 6px; 
}
.bar-fill { height: 100%; transition: width 0.5s ease; border-radius: 10px; }
.fill-high { background: linear-gradient(to right, #56ab2f, #a8e063); } 
.fill-med { background: linear-gradient(to right, #f1c40f, #f39c12); } 
.fill-low { background: linear-gradient(to right, var(--col-rose), var(--col-berry)); }

.usage-controls { font-size: 0.8rem; color: #777; display: flex; justify-content: space-between; align-items: center; }

.calculator-box { background: var(--bg-white); border: 2px dashed var(--col-peach); padding: 25px; border-radius: 20px; }
.calc-row { 
    display: grid; 
    grid-template-columns: 3fr 1fr 1fr 1fr auto; 
    gap: 12px; 
    align-items: center; 
    margin-bottom: 12px; 
    background: #fffcfb; 
    padding: 12px; 
    border-radius: 12px; 
    border: 1px solid #eee; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.total-display { 
    margin-top: 25px; 
    background: linear-gradient(135deg, var(--col-dark), var(--col-plum)); 
    color: var(--bg-white); 
    padding: 25px; 
    border-radius: 15px; 
    text-align: right; 
    box-shadow: 0 10px 20px rgba(76, 29, 61, 0.2);
}
.total-display h3 { margin: 0; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }
.total-display .final-price { font-size: 3rem; font-weight: 700; margin-top: 5px; }

.btn-confirm { 
    background: linear-gradient(45deg, #2ecc71, #27ae60); 
    color: var(--bg-white); border: none; padding: 18px; width: 100%; border-radius: 12px; 
    font-size: 1.1rem; font-weight: bold; margin-top: 20px; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; gap: 10px; 
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3); text-transform: uppercase; letter-spacing: 1px;
}
.btn-confirm:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(39, 174, 96, 0.4); }

.history-table th { background: var(--col-dark); color: var(--bg-white); border-radius: 8px 8px 0 0; }
.history-table td { border: none; border-bottom: 1px solid #eee; }

.alert-section { margin-top: 20px; display: none; animation: fadeIn 0.5s; }
.alert-box { border: 1px solid var(--col-salmon); padding: 0; background: var(--bg-white); border-radius: 12px; overflow: hidden; box-shadow: 0 5px 15px rgba(220, 88, 109, 0.1); }
.alert-item { padding: 15px 20px; border-bottom: 1px solid #eee; display:flex; justify-content: space-between; align-items:center; }
.alert-item strong { color: var(--col-rose); }

/* =========================================
   NOTIFICACIONES (TOAST) - FINAL
   ========================================= */
.notif-toast {
    top: auto !important; right: auto !important; width: auto !important; height: auto !important; margin: 0 !important;
    visibility: hidden; min-width: 300px; max-width: 90%; 
    background-color: #ffffff; color: #333; text-align: left; border-radius: 12px; 
    padding: 16px 20px; position: fixed; z-index: 2147483647 !important;
    left: 50% !important; bottom: 30px !important; transform: translateX(-50%);
    font-size: 15px; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,0.15); border-left: 6px solid #ccc;
    opacity: 0; transition: all 0.4s ease; display: flex; align-items: center; gap: 15px;
}
.notif-toast.show { visibility: visible; opacity: 1; bottom: 50px !important; }
.notif-toast i { font-size: 1.4rem; }
.notif-toast.success { border-left-color: #2ecc71; } .notif-toast.success i { color: #2ecc71; }
.notif-toast.error { border-left-color: #A33757; } .notif-toast.error i { color: #A33757; }

@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media print { body { background: white; } .container { box-shadow: none; border: none; } button, .input-group, .alert-section { display: none !important; } }

/* =========================================
   RESPONSIVE (VISTA MÓVIL OPTIMIZADA)
   ========================================= */
@media (max-width: 768px) {
    /* 1. Ajustes Generales para Estabilidad */
    body { padding: 10px; }
    
    /* REGLA DE ORO: Evita el desbordamiento reduciendo paddings */
    .container { 
        padding: 10px; 
        width: 100%; 
        box-sizing: border-box; 
        border: none; 
        box-shadow: none; 
    }
    
    h2 { font-size: 1.3rem; flex-direction: column; align-items: flex-start; gap: 5px; }
    
    /* 2. Formularios Apilados */
    .input-group { flex-direction: column; align-items: stretch; gap: 15px; padding: 15px; }
    .field, .field-large { width: 100%; min-width: 0; }
    .form-row { flex-direction: column; } 

    /* 3. MODALES */
    .modal-content { width: 95%; margin: 5% auto; padding: 20px; box-sizing: border-box; }

    /* 4. TABLAS CON SCROLL HORIZONTAL (Sin tarjetas, deslizamiento limpio) */
    table {
        display: block;
        overflow-x: auto; /* Permite deslizar */
        white-space: nowrap; /* Evita quiebres de línea */
        -webkit-overflow-scrolling: touch; /* Suavidad en iPhone */
        width: 100%;
        margin-bottom: 20px;
    }
    th, td { padding: 12px 10px; font-size: 0.9rem; } /* Reduce un poco el padding de celda */

    /* 5. CALCULADORA CORREGIDA (Para que no se salga del margen) */
    .calculator-box {
        padding: 15px; /* Reducido de 25px a 15px */
    }
    
    .calc-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "prod prod" 
            "cant cost" 
            "sub del";
        gap: 10px;
        padding: 10px; /* Reducido padding interno */
    }
    
    /* ESTO ES LO QUE ARREGLA EL DESBORDAMIENTO: */
    /* Aseguramos que los items del grid no sean más anchos que su celda */
    .calc-row > div {
        min-width: 0; 
    }
    .calc-row select, .calc-row input {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box; /* Asegura que el padding no sume al ancho */
    }

    .calc-row > div:nth-child(1) { grid-area: prod; }
    .calc-row > div:nth-child(2) { grid-area: cant; }
    .calc-row > div:nth-child(3) { grid-area: cost; }
    .calc-row > div:nth-child(4) { grid-area: sub; } 
    .calc-row > button { grid-area: del; justify-self: end; padding: 10px; }

    /* 6. Botones Grandes para Dedo */
    .btn-save, .btn-confirm, .btn-cancel { width: 100%; margin-top: 10px; padding: 15px; }
    .btn-icon { padding: 8px 12px; margin-left: 5px; font-size: 1.2rem; }
    .total-display .final-price { font-size: 2rem; }
}