/* ============================================
   apple-style.css - Sistema de Pedidos D-Sastre
   Mobile-first responsive design
   ============================================ */

/* --- Reset y base --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.47;
    font-weight: 400;
    letter-spacing: -0.022em;
    margin: 0;
    padding: 8px;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

h2 {
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.004em;
    margin: 0 0 12px 0;
}

h2 #nombre-tienda {
    color: #0071e3;
}

/* --- Navegación y carrito --- */
nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.cart-and-comments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.cart-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 10px;
    transition: background-color 0.2s;
}

.cart-container:hover {
    background-color: #f5f5f7;
}

.cart-image {
    width: 30px;
    height: 30px;
    margin-right: 5px;
    transition: transform 0.2s;
}

.cart-image:hover {
    transform: scale(1.1);
}

.cart-image.carrito-activo {
    filter: hue-rotate(180deg) brightness(1.2);
}

.suma_total {
    background-color: #ff3b30;
    color: white;
    border-radius: 50%;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

.importe_total {
    background-color: #1d1d1f;
    color: white;
    border-radius: 980px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 4px;
}

#pedido-comentarios {
    width: 100%;
    padding: 10px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 16px; /* 16px evita zoom en iOS */
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.2s;
}

#pedido-comentarios:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

/* --- Botones de acción --- */
.acciones-pedido {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.btn-enviar,
.btn-consultar,
.btn-limpiar {
    padding: 12px 24px;
    border-radius: 980px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
    display: block;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

.btn-enviar {
    background-color: #34c759;
    color: #fff;
}
.btn-enviar:hover, .btn-enviar:active {
    background-color: #2db84d;
}
.btn-enviar:disabled {
    background-color: #a8a8a8;
    cursor: not-allowed;
}

.btn-guardar {
    padding: 12px 24px;
    border-radius: 980px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
    display: block;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
    background-color: #ff9500;
    color: #fff;
}
.btn-guardar:hover, .btn-guardar:active {
    background-color: #e88a00;
}
.btn-guardar:disabled {
    background-color: #a8a8a8;
    cursor: not-allowed;
}

/* Indicador carrito guardado */
.carrito-guardado-info {
    padding: 8px 14px;
    background: #e8f4fd;
    color: #0071e3;
    border: 1px solid #b8daff;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 10px;
    text-align: center;
}

.btn-consultar {
    background-color: #0071e3;
    color: #fff;
}
.btn-consultar:hover, .btn-consultar:active {
    background-color: #0077ed;
}

.btn-limpiar {
    background-color: #e8e8ed;
    color: #1d1d1f;
}
.btn-limpiar:hover, .btn-limpiar:active {
    background-color: #d2d2d7;
}

/* --- Mensajes de estado --- */
.mensaje-estado {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.mensaje-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.mensaje-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.mensaje-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Formulario de selección --- */
form {
    margin-bottom: 20px;
}

form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

select {
    font-size: 16px;
    font-weight: 400;
    background-color: #ffffff;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    color: #1d1d1f;
    padding: 10px 14px;
    width: 100%;
    max-width: 300px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='5' viewBox='0 0 10 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0L5 5L10 0H0Z' fill='%23666666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    margin-bottom: 8px;
}

input[type="submit"] {
    background-color: #0071e3;
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 980px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 300px;
    -webkit-tap-highlight-color: transparent;
}

input[type="submit"]:hover, input[type="submit"]:active {
    background-color: #0077ed;
}

/* ============================
   TABLA - MODO TARJETA (MÓVIL)
   ============================ */

/* Ocultar cabecera en móvil */
.tabla-filtrable thead {
    display: none;
}

.tabla-filtrable {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    margin-top: 10px;
    box-shadow: none;
    border-radius: 0;
}

.tabla-filtrable tbody tr {
    display: block;
    background: #fff;
    border: 1px solid #e8e8ed;
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tabla-filtrable tbody tr:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tabla-filtrable tbody tr.fila-con-pedido {
    background-color: #fff8e1 !important;
    border-color: #f6a925;
}

.tabla-filtrable tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: none;
    font-size: 14px;
}

.tabla-filtrable tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 12px;
    color: #6e6e73;
    min-width: 80px;
    flex-shrink: 0;
}

/* Inputs en modo tarjeta */
.tabla-filtrable tbody td .quantity-input,
.tabla-filtrable tbody td .talla-input,
.tabla-filtrable tbody td .obs-input {
    font-size: 16px; /* Evita zoom en iOS */
    padding: 8px;
    border-radius: 8px;
}

.quantity-input {
    width: 4em;
    color: #0071e3;
    background-color: #f5f5f7;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    text-align: center;
    transition: background-color 0.3s ease, font-weight 0.3s ease;
}

.quantity-input:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0,113,227,0.2);
}

.talla-input {
    width: 4em;
    color: #0071e3;
    background-color: #f5f5f7;
    text-transform: uppercase;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    text-align: center;
}

.talla-input:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0,113,227,0.2);
}

.obs-input {
    width: 60%;
    color: #0071e3;
    background-color: #f5f5f7;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    min-width: 0;
}

.obs-input:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0,113,227,0.2);
}

/* PVP */
.celda-pvp {
    white-space: nowrap;
    font-weight: 600;
}

/* Buscador general (móvil) */
.buscador-movil {
    margin-bottom: 10px;
}

.buscador-movil input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    font-size: 16px;
    background: #f5f5f7;
    font-family: inherit;
    -webkit-appearance: none;
}

.buscador-movil input:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
    background: #fff;
}

/* Filtros de columna - ocultos en móvil (se usa el buscador general) */
.columna-filtro {
    display: none;
}

/* ============================
   TABLET (≥600px)
   ============================ */
@media (min-width: 600px) {
    /* Ocultar buscador general en tablet/desktop */
    .buscador-movil {
        display: none;
    }

    body {
        padding: 12px;
    }

    .container {
        padding: 16px;
        border-radius: 14px;
    }

    h2 {
        font-size: 22px;
    }

    nav {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .cart-and-comments {
        flex-direction: row;
        width: auto;
        align-items: center;
    }

    #pedido-comentarios {
        width: 280px;
    }

    .acciones-pedido {
        flex-direction: row;
    }

    .btn-enviar,
    .btn-consultar,
    .btn-guardar,
    .btn-limpiar {
        width: auto;
        font-size: 15px;
    }

    form label {
        display: inline;
        margin-right: 8px;
    }

    select {
        width: 200px;
        display: inline-block;
        margin-bottom: 0;
    }

    input[type="submit"] {
        width: auto;
        display: inline-block;
    }

    /* Tabla: modo horizontal con scroll */
    .tabla-filtrable {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }

    .tabla-filtrable thead {
        display: table-header-group;
    }

    .tabla-filtrable tbody {
        display: table-row-group;
    }

    .tabla-filtrable tbody tr {
        display: table-row;
        border: none;
        border-radius: 0;
        margin-bottom: 0;
        padding: 0;
        box-shadow: none;
    }

    .tabla-filtrable tbody td {
        display: table-cell;
        padding: 8px 6px;
        border-bottom: 1px solid #e8e8ed;
        font-size: 12px;
    }

    .tabla-filtrable tbody td::before {
        display: none;
    }

    .tabla-filtrable tbody td .quantity-input,
    .tabla-filtrable tbody td .talla-input,
    .tabla-filtrable tbody td .obs-input {
        font-size: 13px;
        padding: 4px;
    }

    .quantity-input {
        width: 3.5em;
        border-radius: 4px;
    }

    .talla-input {
        width: 3em;
        border-radius: 4px;
    }

    .obs-input {
        width: 100%;
        min-width: 100px;
        border-radius: 4px;
    }

    .columna-filtro {
        display: block;
        width: 100%;
        margin-top: 4px;
        padding: 4px 6px;
        border: 1px solid #d2d2d7;
        border-radius: 4px;
        font-size: 11px;
    }

    .columna-filtro:focus {
        outline: none;
        border-color: #0071e3;
    }

    th, td {
        padding: 8px 6px;
        text-align: left;
        border-bottom: 1px solid #e8e8ed;
        font-size: 12px;
    }

    th {
        background-color: #f5f5f7;
        font-weight: 600;
        font-size: 12px;
        position: sticky;
        top: 0;
        z-index: 10;
        white-space: nowrap;
    }

    tr:last-child td {
        border-bottom: none;
    }

    tr:nth-child(even) {
        background-color: #fbfbfd;
    }

    tr:hover {
        background-color: #f0f0f5;
    }

    tr.fila-con-pedido {
        background-color: #fff8e1 !important;
    }
}

/* ============================
   DESKTOP (≥1024px)
   ============================ */
@media (min-width: 1024px) {
    body {
        padding: 20px;
    }

    .container {
        padding: 24px;
        border-radius: 18px;
    }

    h2 {
        font-size: 26px;
        margin-bottom: 16px;
    }

    #pedido-comentarios {
        width: 400px;
    }

    th, td {
        padding: 8px 10px;
        font-size: 13px;
    }

    th {
        font-size: 13px;
    }

    .obs-input {
        min-width: 140px;
    }
}

/* ============================
   TABLA GENÉRICA (no .tabla-filtrable)
   Para consulta_pedidos, modales, etc.
   ============================ */
table:not(.tabla-filtrable) {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 12px;
    overflow: hidden;
}

table:not(.tabla-filtrable) th,
table:not(.tabla-filtrable) td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #e8e8ed;
    font-size: 13px;
}

table:not(.tabla-filtrable) th {
    background-color: #f5f5f7;
    font-weight: 600;
    white-space: nowrap;
}

table:not(.tabla-filtrable) tr:last-child td {
    border-bottom: none;
}

table:not(.tabla-filtrable) tr:nth-child(even) {
    background-color: #fbfbfd;
}

/* Scroll horizontal para tablas genéricas en móvil */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.table-responsive table {
    box-shadow: none;
    margin-top: 0;
}

/* ============================
   UTILIDADES TOUCH
   ============================ */

/* Áreas de toque más grandes en móvil */
@media (hover: none) and (pointer: coarse) {
    .btn-enviar,
    .btn-consultar,
    .btn-limpiar,
    input[type="submit"] {
        min-height: 44px;
    }

    select {
        min-height: 44px;
    }

    .quantity-input,
    .talla-input,
    .obs-input {
        min-height: 40px;
    }
}

/* Evitar zoom al hacer focus en inputs en iOS */
@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        font-size: 16px;
    }
}
