/* style.css - Bontal IA Bento Grid & Glassmorphism */

:root {
    /* Color Palette - Bontal IA Tech */
    --primary-color: #0f172a;
    /* Deep slate for emphasis */
    --accent-color: #3b82f6;
    /* Bright blue for actions */
    --accent-hover: #2563eb;

    /* Glassmorphism & Backgrounds */
    --bg-base: #f1f5f9;
    /* Light gray with slight blue tint */
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --panel-bg: rgba(255, 255, 255, 0.85);
    /* Semi-transparent white */

    --border-color: rgba(255, 255, 255, 0.4);
    --border-radius: 20px;
    /* Bento pronounced curves */
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.05);

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Utility Colors */
    --success-color: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning-color: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger-color: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);

    --font-stack: 'Plus Jakarta Sans', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-stack);
    background: var(--bg-gradient);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14px;
    /* Base for tech UI */
    min-height: 100vh;
}

/* Typography Helpers */
h1,
h2,
h3,
h4 {
    color: var(--text-main);
    font-weight: 700;
}

h2 {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

h2 i {
    color: var(--accent-color);
    font-size: 1.2rem;
}

/* Bento Container */
.bento-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    /* Gap directly translates to grid spacing */
    height: 100vh;
    /* Fill viewport */
    overflow: hidden;
}

/* Base Bento Module (Glassmorphism Card) */
.bento-module {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 1.5rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    /* For smooth borders */
}

/* Hover slightly elevates cards except header */
.bento-module:not(.module-header):hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.06);
}

/* Header Widget */
.module-header {
    flex: 0 0 auto;
    padding: 1rem 1.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-titles h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-titles p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-badge {
    background: var(--warning-bg);
    color: #b45309;
    /* Dark orange */
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.success {
    background: var(--success-bg);
    color: #047857;
    /* Dark green */
    border-color: rgba(16, 185, 129, 0.2);
}

.status-badge.error {
    background: var(--danger-bg);
    color: #b91c1c;
    /* Dark red */
    border-color: rgba(239, 68, 68, 0.2);
}

.control-pill {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.3rem 0.8rem 0.3rem 1rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.minimal-select {
    border: none;
    background: transparent;
    font-family: var(--font-stack);
    font-weight: 600;
    color: var(--primary-color);
    outline: none;
    cursor: pointer;
}

.checkbox-pill {
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-pill:hover {
    background: #fff;
}

.checkbox-pill input {
    accent-color: var(--accent-color);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-pill label {
    cursor: pointer;
}

/* Bento Grid System for Main Content */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.25rem;
    flex: 1;
    /* Take remaining height */
    min-height: 0;
    /* Allows scrolling inside children */
}

/* Module Layouts (Desktop > 1200px) */
.module-form {
    grid-column: span 4;
    overflow-y: auto;
}

.module-audit {
    grid-column: span 4;
    overflow-y: auto;
}

.module-preview {
    grid-column: span 4;
    overflow-y: auto;
}

/* Scrollbar Styling for Tech Feel */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* --- WIDGET 1: FORMULACIÓN (Centro-Izquierda) --- */
.form-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
}

.form-section.no-border {
    border-bottom: none;
    margin-bottom: 0;
}

.form-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

/* Inputs form elements */
.bento-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.3rem;
}

.bento-label-inline {
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.mb-10 {
    margin-bottom: 10px;
}

.bento-input {
    width: 100%;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-family: var(--font-stack);
    font-size: 0.85rem;
    transition: all 0.2s ease;
    outline: none;
    color: var(--text-main);
}

.bento-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.bento-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.bento-col {
    flex: 1;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 38px;
}

/* Align with inputs */

/* Chips UI for Ingredients */
.ingredient-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ingredient-input-row .bento-input {
    flex: 2;
}

.ingredient-input-row .num-input {
    flex: 0.8;
}

.ingredient-input-row .dropdown-input {
    flex: 0.8;
    padding: 0.6rem 0.2rem;
}

.btn-icon {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--accent-hover);
}

.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 40px;
}

.empty-chips {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
    width: 100%;
    text-align: center;
    padding: 0.5rem;
}

.ing-chip {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    padding: 0.3rem 0.4rem 0.3rem 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ing-chip:hover {
    transform: translateY(-1px);
}

.chip-name {
    color: var(--text-main);
}

.chip-qty {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 700;
}

.chip-remove {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.chip-remove:hover {
    background: var(--danger-color);
    color: white;
}

.btn-execute {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem;
    width: 100%;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-stack);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.2);
    transition: all 0.3s ease;
}

.btn-execute:hover {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.3);
}

/* --- WIDGET 2: AUDITORÍA (Centro-Derecha) --- */
.audit-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.audit-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-light);
    text-align: center;
    gap: 1rem;
}

.audit-empty-state i {
    font-size: 3rem;
    color: rgba(0, 0, 0, 0.05);
}

/* Audit Cards (Replacement for basic table) */
.audit-card {
    background: white;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.3s ease;
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
    transform: translateX(-10px);
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.acard-warning {
    border-left: 4px solid var(--warning-color);
    background: linear-gradient(90deg, var(--warning-bg) 0%, white 5%);
}

.acard-critical {
    border-left: 4px solid var(--danger-color);
    background: linear-gradient(90deg, var(--danger-bg) 0%, white 5%);
}

.acard-info {
    border-left: 4px solid var(--accent-color);
}

.acard-approved {
    opacity: 0.7;
    filter: grayscale(0.5);
    border-left-color: var(--success-color);
}

.acard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.acard-phase {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
}

.acard-detail {
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.2rem;
}

.acard-detail strong {
    color: var(--danger-color);
}

/* Highlight normative text if needed */

.acard-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-audit {
    flex: 1;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    font-family: var(--font-stack);
}

.btn-audit.approve {
    color: #059669;
    background: var(--success-bg);
}

.btn-audit.approve:hover {
    background: #a7f3d0;
    border-color: #34d399;
}

.btn-audit.reject {
    color: #dc2626;
    background: var(--danger-bg);
}

.btn-audit.reject:hover {
    background: #fecaca;
    border-color: #f87171;
}

.acard-comment {
    width: 100%;
    margin-top: 0.5rem;
    background: transparent;
    border: none;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
    padding: 0.5rem 0;
    font-size: 0.8rem;
    font-family: var(--font-stack);
    outline: none;
    color: var(--text-muted);
    resize: none;
}

.acard-comment:focus {
    color: var(--text-main);
    border-top-color: var(--accent-color);
}

/* --- WIDGET 3: LIVE PREVIEW (Derecha) --- */
.preview-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    padding: 0.3rem;
    margin-bottom: 1.25rem;
}

.ptab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.5rem;
    font-family: var(--font-stack);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ptab-btn:hover {
    color: var(--text-main);
}

.ptab-btn.active {
    background: white;
    color: var(--accent-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.ptab-pane {
    display: none;
}

.ptab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.mockup-container {
    background: url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="1.5" fill="%23e2e8f0"/></svg>') calc(50% - 10px) calc(50% - 10px);
    background-color: #f1f5f9;
    border: 1px dashed rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    height: calc(100% - 3rem);
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 1.5rem;
}

/* Fullscreen Mode Classes */
.module-preview.fullscreen-active {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 99999;
    border-radius: 0;
    margin: 0;
    padding: 2rem;
    background: white;
    box-shadow: none;
    overflow-y: hidden;
}

.module-preview.fullscreen-active .mockup-container {
    height: calc(100vh - 8rem);
}

.mockup-frame {
    background: white;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    /* Deep drop shadow for paper effect */
    border-radius: 0;
    /* Nutrition label is usually square corners */
    padding: 15px;
    width: 100%;
    max-width: 320px;
}

.mockup-placeholder {
    color: var(--text-light);
    font-size: 0.85rem;
    text-align: center;
    padding: 2rem 0;
    font-weight: 600;
}

/* Base Nutritional Table Styles (Clean typography) */
.nutrition-img-table {
    width: 100%;
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
    color: black;
    background: white;
    font-size: 0.85rem;
    border: 2px solid black;
}

.nutrition-img-table td {
    border: 1px solid black;
    padding: 4px 6px;
    vertical-align: middle;
}

.nutrition-img-table .nutri-main-title {
    text-align: center;
    font-weight: bold;
    font-size: 1.4rem;
    padding: 8px;
}

.nutrition-img-table .thick-bot {
    border-bottom: 4px solid black !important;
}

.nutrition-img-table .bold {
    font-weight: bold;
}

.nutrition-img-table .lg-text {
    font-size: 1.1rem;
}

.nutrition-img-table .center-col {
    text-align: center;
}

.nutrition-img-table .indent-1 {
    padding-left: 15px;
}

.nutrition-img-table .indent-2 {
    padding-left: 25px;
}

.nutrition-img-table .nutri-footer {
    font-size: 0.75rem;
    padding-top: 5px;
    border-top: 2px solid black;
}

/* Mobile FAB */
.fab-btn {
    display: none;
}

.hidden {
    display: none !important;
}

/* Preview Blocks and Copy Buttons */
.preview-block {
    width: 100%;
    max-width: 380px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.btn-copy-sm {
    margin-top: 1rem;
    background: white;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-stack);
}

.btn-copy-sm:hover {
    background: #f1f5f9;
    color: var(--primary-color);
    border-color: #94a3b8;
}

/* Responsive Media Queries */
/* Optional Nutrients Checkbox Grid */
.optional-nutrients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.opt-checkbox {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-main);
    cursor: pointer;
}

.opt-checkbox input {
    accent-color: var(--accent-color);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    border-radius: var(--border-radius);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay:not(.hidden) .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 1rem;
}

.modal-body {
    overflow-y: auto;
    flex: 1;
    padding-right: 10px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.modal-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 1200px) {

    /* Tablet Portrait & Mobile */
    .bento-container {
        height: auto;
        overflow: visible;
        padding: 1rem;
    }

    .bento-grid {
        grid-template-columns: 1fr;
        /* Stack everything */
    }

    .module-form,
    .module-audit,
    .module-preview {
        grid-column: span 1;
        overflow: visible;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-execute {
        display: none;
    }

    /* Replaced by FAB */

    .fab-btn {
        display: flex;
        position: fixed;
        bottom: 20px;
        right: 20px;
        background-color: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50%;
        /* Circle FAB for mobile */
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        box-shadow: 0 10px 25px rgba(15, 23, 42, 0.4);
        z-index: 1000;
        justify-content: center;
        align-items: center;
        transition: transform 0.2s;
    }

    .fab-btn:hover {
        transform: scale(1.05);
    }
}

/* Mobile Specific Tweaks */
@media (max-width: 768px) {
    .bento-row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .bento-col {
        width: 100%;
    }
    
    .ingredient-input-row {
        flex-wrap: wrap;
    }
    
    .ingredient-input-row .bento-input:first-child {
        flex: 1 1 100%;
        margin-bottom: 5px;
    }
    
    .ingredient-input-row .num-input,
    .ingredient-input-row .dropdown-input,
    .ingredient-input-row .btn-icon {
        flex: 1;
    }
    
    .ts-tabs {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .ts-tabs .bento-btn {
        flex: 1 1 45%; 
        font-size: 0.75rem;
        padding: 8px 5px;
        text-align: center;
    }
}