/* ==========================================================================
   GESTIÓN QUIMIAPAN V2 - PORTAL GLOBAL DESIGN SYSTEM (3D LUXURY)
   Ubicación: modules/portal/assets/css/gq-portal.css
   ========================================================================== */

:root {
    --q-green-dark: #142416;
    --q-green-main: #1D3621;
    --q-sand: #D6CDBA;
    --q-cream: #F2EFE9;
    --q-white: #FFFFFF;
    
    --shadow-soft: 0 8px 24px rgba(29, 54, 33, 0.08);
    --shadow-deep: 0 12px 32px rgba(20, 36, 22, 0.25);
    --shadow-float: 0 20px 40px rgba(29, 54, 33, 0.12);
    
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --q-radius-lg: 20px;
    --q-radius-md: 12px;
}

/* --- 1. RESET Y ESTRUCTURA ANTI-SCROLL --- */
*, *::before, *::after { box-sizing: border-box !important; }

/* ELIMINAR INTERFERENCIA DE WORDPRESS (Mata espacios laterales Y el techo) */
.wp-site-blocks, 
.entry-content, 
.has-global-padding,
.is-layout-constrained {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

.wp-site-blocks > *, 
.entry-content > *,
.is-layout-constrained > * {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

html, body {
    margin: 0 !important; padding: 0 !important; margin-top: 0 !important;
    width: 100%; min-height: 100vh; overflow-x: hidden; 
    background-color: var(--q-cream); font-family: var(--font-body);
    color: var(--q-green-dark); -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* --- 2. LAYOUT PRINCIPAL EDGE-TO-EDGE --- */
.gq-app-wrapper { display: flex; min-height: 100vh; width: 100vw !important; max-width: 100% !important; position: relative; }
.gq-central-panel { flex: 1; display: flex; width: 100%; justify-content: center; }
.gq-portal-wrapper { display: flex; width: 100%; max-width: 100%; position: relative; }

/* --- 3. SIDEBAR DESLIZANTE --- */
.gq-portal-sidebar {
    position: fixed; height: 100vh; left: -280px; top: 0; width: 280px;
    background: var(--q-green-dark); display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 9999; box-shadow: var(--shadow-deep);
}
.gq-portal-sidebar.open { transform: translateX(280px); }

.gq-sidebar-header { padding: 40px 20px 10px; text-align: center; }
.gq-sidebar-logo { width: 140px !important; height: auto !important; max-width: 100%; object-fit: contain !important; margin: 0 auto !important; display: block !important; }
.gq-sidebar-nav { padding: 10px 0 20px 0; display: flex; flex-direction: column; flex: 1; }

/* CORRECCIÓN: BLINDAJE CONTRA EL TEMA DE WORDPRESS CON !IMPORTANT */
.gq-nav-item { 
    padding: 14px 30px; 
    color: var(--q-sand) !important; 
    text-decoration: none !important; 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    transition: all 0.3s ease; 
    font-weight: 500; 
    font-size: 0.9rem; 
    border-left: 4px solid transparent; 
}
.gq-nav-item:hover, .gq-nav-item.active { 
    background: rgba(214, 205, 186, 0.05); 
    color: var(--q-white) !important; 
    border-left-color: var(--q-sand) !important; 
}

.gq-nav-item .dashicons { font-size: 18px; width: 18px; height: 18px; }
.gq-nav-separator { height: 1px; background-color: rgba(214, 205, 186, 0.15); margin: 15px 30px; }

/* --- 4. TOPBAR 100% EDGE-TO-EDGE --- */
.gq-portal-main { width: 100%; display: flex; flex-direction: column; min-width: 0; background: var(--q-cream); }
.gq-portal-topbar {
    background: var(--q-white); padding: 0 15px !important; display: flex; justify-content: space-between; align-items: center; 
    box-shadow: 0 4px 12px rgba(29, 54, 33, 0.05); height: 60px; position: sticky; top: 0; z-index: 100; 
    width: 100% !important; margin: 0 !important; border-radius: 0 !important; border-left: none !important; border-right: none !important; border-top: none !important;
}
.gq-topbar-left, .gq-topbar-right { width: 50px; display: flex; align-items: center; }
.gq-topbar-right { justify-content: flex-end; }
.gq-topbar-logo { flex-grow: 1; display: flex; justify-content: center; align-items: center; }
.gq-sidebar-toggle { background: none; border: none; color: var(--q-green-main); cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: flex-start; }
.gq-sidebar-toggle .dashicons { font-size: 28px; width: 28px; height: 28px; }
.qm-topbar-logo-img { height: 35px; width: auto; max-width: 150px; object-fit: contain; display: block; transition: height 0.3s ease; }
.gq-topbar-profile { color: var(--q-green-main); text-decoration: none; display: flex; align-items: center; justify-content: center; transition: color 0.3s ease;}
.gq-topbar-profile .dashicons { font-size: 24px; width: 24px; height: 24px; }

/* --- 5. COMPONENTES MÓVILES --- */
.gq-portal-content { padding: 20px 0 40px 0 !important; flex: 1; width: 100%; }
.qm-page-header { display: flex; flex-direction: column; align-items: center; justify-content: center; margin-bottom: 20px; gap: 10px; width: 100%; padding: 0 15px; }
.qm-page-title { font-family: var(--font-mono); font-size: 1.25rem; color: var(--q-green-dark); font-weight: 700; text-transform: uppercase; letter-spacing: 2px; margin: 0; opacity: 0.6; border-bottom: 1px dashed rgba(214, 205, 186, 0.6); padding-bottom: 8px; text-align: center; }
.qm-header-actions { display: flex; gap: 10px; justify-content: center; width: 100%; }

/* Botones */
.qm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 16px; border-radius: 50px; font-family: var(--font-body);
    font-weight: 600; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 1px;
    cursor: pointer; transition: all 0.3s ease; border: none;
    text-decoration: none !important;
}
.qm-btn-primary { background: var(--q-green-main); color: var(--q-sand); box-shadow: 0 4px 12px rgba(29, 54, 33, 0.2); }
.qm-btn-primary:hover { background: var(--q-green-dark); transform: translateY(-2px); }
.qm-btn-outline { background: transparent; color: var(--q-green-main); border: 1px solid var(--q-green-main); }
.qm-btn-outline:hover { background: var(--q-green-main); color: var(--q-sand); }

/* Tarjetas borde a borde en móvil */
.qm-card {
    background: var(--q-white); border-radius: 0 !important; box-shadow: var(--shadow-soft); 
    margin-bottom: 20px; width: 100% !important; margin-left: 0 !important; margin-right: 0 !important;
    border-top: 1px solid rgba(214, 205, 186, 0.3); border-bottom: 1px solid rgba(214, 205, 186, 0.3);
    border-left: none !important; border-right: none !important;
}
.qm-card-header { padding: 15px; border-bottom: 1px solid rgba(214, 205, 186, 0.3); display: flex; justify-content: space-between; align-items: center; }
.qm-card-title { font-family: var(--font-body); font-size: 1rem; color: var(--q-green-main); font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: 1px; }
.qm-card-body { padding: 15px 0; }

/* --- 6. TABLAS ULTRAPRIMIDAS PARA MÓVIL --- */
.qm-table-wrapper { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 5px; }
.qm-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.qm-table th, .qm-table td {
    padding: 12px 8px; text-align: left; vertical-align: middle; border-bottom: 1px solid rgba(214, 205, 186, 0.2); 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-body); font-size: 0.85rem;
}
.qm-table th { font-weight: 600; color: var(--q-green-main); text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.65rem; background-color: rgba(214, 205, 186, 0.1); }
.qm-table th:nth-child(1), .qm-table td:nth-child(1) { width: 40%; font-weight: 600; color: var(--q-green-main); padding-left: 15px; }
.qm-table th:nth-child(2), .qm-table td:nth-child(2) { width: 30%; }
.qm-table th:nth-child(3), .qm-table td:nth-child(3) { width: 20%; text-align: right; }
.qm-table th:nth-child(4), .qm-table td:nth-child(4) { 
    width: 10%; 
    text-align: right; 
    padding-right: 15px; 
    overflow: visible; 
    text-overflow: clip; 
}
.qm-table .gq-portal-delete-cut { 
    height: 24px !important; width: 24px !important; padding: 0 !important; 
    display: inline-flex !important; align-items: center; justify-content: center;
    margin-left: auto; border: 1px solid #D32F2F !important; border-radius: 4px;
    text-decoration: none !important;
}
.qm-table .gq-portal-delete-cut .dashicons { font-size: 14px !important; width: 14px !important; height: 14px !important; color: #D32F2F; margin: 0; }

/* --- 7. FORMULARIOS Y CONTROLES ESTANDARIZADOS (UNIFICADOS) --- */

.qm-input {
    width: 100%; 
    height: 50px; 
    border-radius: 8px; 
    border: 1px solid rgba(214, 205, 186, 0.8); 
    padding: 10px 15px; 
    font-family: var(--font-body); 
    font-size: 1rem; 
    color: var(--q-green-main); 
    background: #fff;
    transition: all 0.2s ease;
    box-sizing: border-box;
}
textarea.qm-input {
    height: auto;
    min-height: 80px;
    resize: vertical;
}
select.qm-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231D3621%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px auto;
}

.qm-input-hero {
    font-size: 2.5rem; 
    text-align: center; 
    height: 70px; 
    color: var(--q-green-main); 
    border: 2px solid var(--q-sand); 
    background: var(--q-cream); 
    border-radius: 12px; 
    width: 100%;
    font-family: var(--font-mono);
    font-weight: 700;
}
.qm-input:focus, .qm-input-hero:focus { 
    background: #fff; 
    outline: none; 
    border-color: var(--q-green-main); 
    box-shadow: 0 0 0 3px rgba(29, 54, 33, 0.1);
}

.qm-radio-list { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    max-height: 250px; 
    overflow-y: auto; 
    padding-right: 5px; 
}
.qm-radio-list::-webkit-scrollbar { width: 6px; }
.qm-radio-list::-webkit-scrollbar-track { background: rgba(214, 205, 186, 0.2); border-radius: 10px; }
.qm-radio-list::-webkit-scrollbar-thumb { background: rgba(29, 54, 33, 0.3); border-radius: 10px; }

.qm-radio-card input[type="radio"],
.qm-radio-card input[type="checkbox"] { 
    display: none; 
}
.qm-radio-content { 
    border: 1px solid rgba(214, 205, 186, 0.6); 
    border-radius: 8px; 
    padding: 12px 15px; 
    cursor: pointer; 
    transition: all 0.2s; 
    background: #fff; 
    color: var(--q-green-main); 
    display: flex; 
    flex-direction: row; 
    align-items: center; 
    justify-content: flex-start; 
    gap: 12px; 
    font-weight: 500; 
    font-size: 0.9rem; 
}
.qm-radio-content .dashicons { font-size: 18px; width: 18px; height: 18px; opacity: 0.7; }

.qm-radio-card input:checked + .qm-radio-content { 
    border-color: var(--q-green-main); 
    background: var(--q-green-main); 
    color: var(--q-white); 
    box-shadow: 0 4px 10px rgba(29, 54, 33, 0.15);
}
.qm-radio-card input:checked + .qm-radio-content .dashicons { opacity: 1; color: var(--q-white); }
.qm-radio-card input:checked + .qm-radio-content span, 
.qm-radio-card input:checked + .qm-radio-content strong { color: var(--q-white) !important; }

/* COMPONENTE GLOBAL PORTAL: SACKS (Sacos de Almacén/Trilla con Altura Dinámica) */
.sack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 15px;
    padding: 10px 0;
}

.sack-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end; /* Alinea los costales hacia abajo */
    width: 100%;
    min-height: 95px; /* Altura mínima para permitir crecimiento */
    transition: transform 0.2s, opacity 0.2s, filter 0.2s;
    cursor: pointer;
}

.sack-item:hover {
    transform: translateY(-3px);
}

.sack-icon {
    width: 50px;
    /* Altura dinámica usando CSS variable, mínimo 35px para que se lea el número */
    height: max(35px, calc(60px * var(--fill-level, 1))); 
    background-color: #dca546;
    border: 1px solid #b58532;
    border-radius: 4px 4px 15px 15px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: inset 2px -2px 5px rgba(0,0,0,0.1);
    margin-bottom: 5px;
    transition: all 0.3s ease;
}

.sack-icon::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 0;
    width: 100%;
    height: 6px;
    background-color: #dca546;
    border-radius: 4px;
    border: 1px solid #b58532;
    z-index: 0;
    transition: all 0.2s ease;
}

.sack-meta {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--q-green-dark);
    text-align: center;
    line-height: 1.2;
    transition: color 0.2s ease;
}

.sack-meta small {
    display: block;
    font-weight: 700;
    font-size: 0.65rem;
    color: rgba(20, 36, 22, 0.6);
    margin-top: 2px;
    transition: color 0.2s ease;
}

input.qm-hide {
    display: none !important;
}

label input[type="checkbox"].qm-hide:checked + .sack-item {
    opacity: 0.65;
}

label input[type="checkbox"].qm-hide:checked + .sack-item .sack-icon {
    background-color: #fff;
    border-color: #ccc;
    color: #999;
    box-shadow: none;
}

label input[type="checkbox"].qm-hide:checked + .sack-item .sack-icon::before {
    background-color: #fff;
    border-color: #ccc;
}

label input[type="checkbox"].qm-hide:checked + .sack-item .sack-meta,
label input[type="checkbox"].qm-hide:checked + .sack-item .sack-meta small {
    color: #999;
}

/* --- 8. AJUSTES PARA PC --- */
@media (min-width: 993px) {
    .gq-portal-wrapper { width: 65%; max-width: 1200px; margin: 0 auto; } 
    .gq-portal-topbar { height: 75px; padding: 0 30px !important; margin: 25px 15px 0 15px !important; border-radius: var(--q-radius-lg) !important; border: 1px solid rgba(214, 205, 186, 0.4) !important; }
    .qm-topbar-logo-img { height: 50px; }
    .gq-sidebar-toggle .dashicons { font-size: 32px; width: 32px; height: 32px; }
    .gq-portal-content { padding: 40px 15px !important; }
    .qm-card { border-radius: var(--q-radius-lg) !important; margin-left: 0 !important; margin-right: 0 !important; border-left: 1px solid rgba(214, 205, 186, 0.3) !important; border-right: 1px solid rgba(214, 205, 186, 0.3) !important; }
    .qm-card-body { padding: 20px; }
    .qm-table th:nth-child(1), .qm-table td:nth-child(1) { padding-left: 20px; }
    .qm-table th:nth-child(4), .qm-table td:nth-child(4) { padding-right: 20px; }
}
.gq-portal-content > h3, .gq-portal-content > div[style*="display: grid"] { padding-left: 15px; padding-right: 15px; }
@media (min-width: 993px) { .gq-portal-content > h3, .gq-portal-content > div[style*="display: grid"] { padding-left: 0; padding-right: 0; } }