/* ============================================
   ERP PANADERIA - Sistema de Gestión Profesional
   Paleta: Tonos cálidos de panadería artesanal
   ============================================ */

/* === VARIABLES CSS === */
:root {
    --color-primary: #8B5E3C;
    --color-primary-dark: #6B4226;
    --color-primary-light: #A67B5B;
    --color-secondary: #D4A574;
    --color-accent: #C9944A;
    --color-accent-hover: #B8833A;
    --color-bg: #FAF6F1;
    --color-bg-card: #FFFFFF;
    --color-bg-sidebar: #3E2723;
    --color-bg-sidebar-hover: #4E342E;
    --color-bg-sidebar-active: #5D4037;
    --color-text: #3E2723;
    --color-text-light: #6D4C41;
    --color-text-muted: #8D6E63;
    --color-text-white: #FAF6F1;
    --color-border: #D7CCC8;
    --color-border-light: #EFEBE9;
    --color-success: #558B2F;
    --color-success-bg: #F1F8E9;
    --color-danger: #C62828;
    --color-danger-bg: #FFEBEE;
    --color-danger-hover: #B71C1C;
    --color-warning: #F57F17;
    --color-warning-bg: #FFF8E1;
    --color-info: #1565C0;
    --color-info-bg: #E3F2FD;
    --shadow-sm: 0 1px 3px rgba(62, 39, 35, 0.08);
    --shadow-md: 0 4px 12px rgba(62, 39, 35, 0.1);
    --shadow-lg: 0 8px 30px rgba(62, 39, 35, 0.12);
    --shadow-xl: 0 12px 40px rgba(62, 39, 35, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 17px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
}

/* === LAYOUT === */
.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    width: 270px;
    background: linear-gradient(180deg, var(--color-bg-sidebar) 0%, #2C1810 100%);
    color: var(--color-text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.sidebar-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.sidebar-logo .logo-img-wrapper {
    width: 80px;
    height: 80px;
    background: #fdf6ec;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-logo .logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-brand-name {
    font-family: 'Georgia', serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 0.3px;
    line-height: 1.3;
}

.sidebar-subtitle {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 3px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.35);
    padding: 16px 16px 8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 3px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    position: relative;
}

.nav-item:hover {
    background: var(--color-bg-sidebar-hover);
    color: #FFF;
}

.nav-item.active {
    background: var(--color-bg-sidebar-active);
    color: #FFF;
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--color-accent);
    border-radius: 0 4px 4px 0;
}

.nav-item .nav-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.15rem;
    flex-shrink: 0;
}

.nav-item .nav-icon.icon-dashboard { background: rgba(201, 148, 74, 0.2); }
.nav-item .nav-icon.icon-proveedores { background: rgba(85, 139, 47, 0.2); }
.nav-item .nav-icon.icon-ingredientes { background: rgba(21, 101, 192, 0.2); }
.nav-item .nav-icon.icon-calculadora { background: rgba(230, 126, 34, 0.2); }

.sidebar-user-info {
    margin: 8px 16px 8px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    font-size: 22px;
    opacity: 0.7;
    flex-shrink: 0;
}

.sidebar-user-details {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    color: rgba(255,255,255,0.92);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-tienda {
    color: rgba(255,255,255,0.55);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.sidebar-user-rol {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: 3px;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
}

.btn-logout {
    width: 100%;
    padding: 9px 12px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: background 0.2s;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.btn-shutdown {
    width: 100%;
    padding: 10px 12px;
    background: #C62828;
    color: #FFFFFF;
    border: 1px solid #E53935;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(198, 40, 40, 0.4);
}

.btn-shutdown:hover {
    background: #E53935;
    color: #FFFFFF;
    border-color: #EF5350;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.5);
    transform: translateY(-1px);
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    margin-left: 270px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === TOP BAR === */
.top-bar {
    background: var(--color-bg-card);
    padding: 18px 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-bar-title h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
}

.top-bar-breadcrumb {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.top-bar-date {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* === PAGE CONTENT === */
.page-content {
    padding: 32px 36px;
    flex: 1;
}

/* === SECTION (module page) === */
.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* === DASHBOARD === */
.dashboard-welcome {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 40px 44px;
    color: white;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}

.dashboard-welcome::after {
    content: '';
    position: absolute;
    right: -40px;
    top: -40px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.dashboard-welcome::before {
    content: '';
    position: absolute;
    right: 60px;
    bottom: -30px;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 50%;
}

.dashboard-welcome h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.dashboard-welcome p {
    font-size: 1rem;
    opacity: 0.85;
    max-width: 600px;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    transition: var(--transition);
    cursor: pointer;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 16px;
}

.stat-card .stat-icon.icon-proveedores { background: var(--color-success-bg); color: var(--color-success); }
.stat-card .stat-icon.icon-recepciones { background: var(--color-info-bg); color: var(--color-info); }
.stat-card .stat-icon.icon-productos { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-card .stat-icon.icon-alertas { background: var(--color-danger-bg); color: var(--color-danger); }

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dashboard-modules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.module-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.module-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
    border-color: var(--color-secondary);
}

.module-card .module-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.module-card .module-icon.bg-proveedores {
    background: linear-gradient(135deg, #558B2F, #7CB342);
    color: white;
}

.module-card .module-icon.bg-ingredientes {
    background: linear-gradient(135deg, #1565C0, #42A5F5);
    color: white;
}

.module-card .module-info h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
}

.module-card .module-info p {
    font-size: 0.92rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.module-card .module-arrow {
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    align-self: center;
    transition: var(--transition);
}

.module-card:hover .module-arrow {
    color: var(--color-primary);
    transform: translateX(4px);
}

/* === CARDS & PANELS === */
.card {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-bg);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 28px;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(139, 94, 60, 0.3);
}

.btn-accent {
    background: var(--color-accent);
    color: white;
}

.btn-accent:hover {
    background: var(--color-accent-hover);
    box-shadow: 0 4px 12px rgba(201, 148, 74, 0.3);
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover {
    background: #33691E;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background: var(--color-danger-hover);
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-border);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    background: rgba(139, 94, 60, 0.05);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* === FORMS === */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group label .required {
    color: var(--color-danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 11px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--color-text);
    background: var(--color-bg-card);
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.12);
}

.form-control::placeholder {
    color: var(--color-text-muted);
    font-style: italic;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238D6E63' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

/* === SEARCH INPUT === */
.search-container {
    position: relative;
}

.search-container .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.search-container .form-control {
    padding-left: 42px;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg-card);
    border: 2px solid var(--color-primary-light);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: var(--shadow-md);
    display: none;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.autocomplete-item:hover {
    background: var(--color-bg);
}

.autocomplete-item .item-name {
    font-weight: 600;
    color: var(--color-text);
}

.autocomplete-item .item-detail {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

/* === TABLE === */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

thead {
    background: var(--color-bg);
}

thead th {
    padding: 14px 18px;
    text-align: left;
    font-weight: 700;
    color: var(--color-text-light);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
    vertical-align: middle;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: rgba(212, 165, 116, 0.06);
}

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

.table-actions {
    display: flex;
    gap: 6px;
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

/* === MODAL === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(62, 39, 35, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 24px 28px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--color-text-muted);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.modal-body {
    padding: 28px;
}

.modal-footer {
    padding: 20px 28px;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--color-bg);
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    max-width: 450px;
    animation: toastSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    font-weight: 500;
}

.toast.toast-exit {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

.toast-success {
    background: var(--color-success);
    color: white;
}

.toast-error {
    background: var(--color-danger);
    color: white;
}

.toast-warning {
    background: var(--color-warning);
    color: white;
}

.toast-info {
    background: var(--color-info);
    color: white;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 60px 40px;
    color: var(--color-text-muted);
}

.empty-state .empty-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-text-light);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto;
}

/* === FILTER BAR === */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-bar .form-control {
    max-width: 250px;
}

/* === DETAIL VIEW (HISTORIAL) === */
.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.detail-header .back-btn {
    width: 40px;
    height: 40px;
    border: 2px solid var(--color-border);
    background: var(--color-bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--color-text-muted);
    transition: var(--transition);
}

.detail-header .back-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.detail-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.detail-info-item {
    background: var(--color-bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
}

.detail-info-item .label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.detail-info-item .value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

/* === TABS === */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border-light);
    margin-bottom: 24px;
    gap: 4px;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab:hover {
    color: var(--color-text);
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* === CONFIRM DIALOG === */
.confirm-dialog {
    text-align: center;
    padding: 12px 0;
}

.confirm-dialog .confirm-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--color-danger);
}

.confirm-dialog h3 {
    font-size: 1.15rem;
    margin-bottom: 8px;
}

.confirm-dialog p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.confirm-dialog .btn-group {
    justify-content: center;
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-modules {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-header, .sidebar-subtitle, .nav-section-title, .sidebar-footer {
        display: none;
    }
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    .nav-item span:not(.nav-icon) {
        display: none;
    }
    .main-content {
        margin-left: 60px;
    }
    .page-content {
        padding: 20px 16px;
    }
    .top-bar {
        padding: 14px 16px;
    }
    .dashboard-welcome {
        padding: 28px 24px;
    }
}

/* === SCROLLBAR CUSTOM === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* === LOADING SPINNER === */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   CALCULADORA PANADERO
   ============================================ */

/* Dashboard module card */
.module-card .module-icon.bg-calculadora {
    background: linear-gradient(135deg, #E67E22, #F39C12);
    color: white;
}

.stat-card .stat-icon.icon-formulas {
    background: #FFF3E0;
    color: #E67E22;
}

/* Ingredientes table with inline inputs */
.ingredientes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.ingredientes-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    color: var(--color-text-light);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid var(--color-border);
    background: var(--color-bg);
    white-space: nowrap;
}

.ingredientes-table tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}

.ingredientes-table input,
.ingredientes-table select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.92rem;
    color: var(--color-text);
    background: var(--color-bg-card);
    font-family: inherit;
    transition: border-color 0.2s;
}

.ingredientes-table input:focus,
.ingredientes-table select:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 2px rgba(139, 94, 60, 0.1);
}

.ingredientes-table input[type="number"] {
    text-align: right;
    min-width: 80px;
}

.ingredientes-table .col-tipo { width: 120px; }
.ingredientes-table .col-nombre { min-width: 160px; }
.ingredientes-table .col-porcentaje { width: 100px; }
.ingredientes-table .col-peso { width: 100px; }
.ingredientes-table .col-precio { width: 110px; }
.ingredientes-table .col-coste { width: 90px; }
.ingredientes-table .col-acciones { width: 90px; text-align: center; }

.ingredientes-table .peso-calculado {
    font-weight: 600;
    color: var(--color-primary);
    text-align: right;
    padding-right: 4px;
}

.ingredientes-table .coste-calculado {
    font-weight: 600;
    color: var(--color-success);
    text-align: right;
}

/* Ingredient type badges */
.ingredient-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Los colores de tipo se aplican dinámicamente via inline style desde la BD */

/* Add ingredient buttons */
.btn-add-ingredient {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-add-ingredient:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(139, 94, 60, 0.04);
}

.add-ingredients-bar {
    padding: 12px 0;
    margin-top: 4px;
    position: relative;
    z-index: 10;
}

.add-ingredient-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.add-ingredient-selector .search-container {
    min-width: 250px;
}

.add-ingredient-selector .autocomplete-dropdown {
    z-index: 300;
}

.add-ingredient-selector .form-control {
    font-size: 0.95rem;
}

/* Calculator summary panel */
.calc-summary {
    background: linear-gradient(135deg, #FFF8F0, #FFF3E0);
    border: 1px solid #FFCC80;
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-top: 20px;
}

.calc-summary h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.calc-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.summary-item {
    background: white;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    border: 1px solid var(--color-border-light);
}

.summary-item .summary-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.summary-item .summary-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-primary);
}

.summary-item .summary-value.text-success { color: var(--color-success); }
.summary-item .summary-value.text-info { color: var(--color-info); }
.summary-item .summary-value.text-warning { color: var(--color-warning); }

/* Formula detail view */
.formula-detail {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    padding: 28px;
    margin-bottom: 24px;
}

.formula-detail h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.formula-detail .formula-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.formula-detail .formula-meta span {
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

/* Process info grid */
.process-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.process-info-item {
    background: var(--color-bg);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
}

.process-info-item .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.process-info-item .value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

/* Editor layout */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.editor-section {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    overflow: visible;
    position: relative;
    z-index: 1;
}

/* Sections with dropdowns need higher z-index so autocomplete floats above next section */
.editor-section:has(.autocomplete-dropdown) {
    z-index: 2;
}

.editor-section-header {
    padding: 16px 24px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border-light);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-section-body {
    padding: 20px 24px;
}

/* Inline action buttons in ingredient rows */
.ingredientes-table .btn-row-action {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    background: transparent;
    color: var(--color-text-muted);
}

.ingredientes-table .btn-row-action:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.ingredientes-table .btn-row-action.btn-row-delete:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

/* Quick calculator input section */
.quick-calc-header {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.quick-calc-header .form-group {
    margin-bottom: 0;
}

/* Formula list actions */
.formula-actions {
    display: flex;
    gap: 4px;
}

/* Categorias management */
.categorias-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.categoria-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: var(--transition);
}

.categoria-card:hover {
    box-shadow: var(--shadow-sm);
}

.categoria-card h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.categoria-card p {
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

/* Formula scaling panel (detail view) */
.scaling-panel {
    background: linear-gradient(135deg, #E8F5E9, #F1F8E9);
    border: 2px solid #81C784;
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.scaling-panel h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #2E7D32;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.scaling-inputs {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.scaling-inputs .form-group {
    margin-bottom: 0;
}

.scaling-inputs .form-group label {
    font-size: 0.82rem;
    color: #2E7D32;
}

.scaling-inputs .form-control {
    border-color: #81C784;
    font-weight: 600;
    font-size: 1.05rem;
}

.scaling-inputs .form-control:focus {
    border-color: #2E7D32;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}

.scaling-divider {
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
    padding-bottom: 2px;
}

/* Harina total indicator (green=100%, red=other) */
.harina-total-indicator {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-left: 12px;
    transition: var(--transition);
}

.harina-total-indicator.ok {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.harina-total-indicator.error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

/* Editor buttons bar */
.editor-actions-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-light);
    margin-top: 20px;
}

/* View mode (readonly editor) */
.editor-readonly .form-control,
.editor-readonly select,
.editor-readonly textarea {
    pointer-events: none;
    opacity: 0.85;
    background: var(--color-bg);
}

.editor-readonly .ingredientes-table input,
.editor-readonly .ingredientes-table select {
    pointer-events: none;
    opacity: 0.85;
    background: var(--color-bg);
}

.editor-readonly .add-ingredients-bar,
.editor-readonly .btn-row-action {
    display: none;
}

/* ===== TABLA NUTRICIONAL (Editor) ===== */

.nutri-editor-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-top: 4px;
}

.nutri-editor-table thead th {
    padding: 9px 14px;
    background: var(--color-cream);
    color: var(--color-primary);
    font-weight: 700;
    border-bottom: 2px solid var(--color-primary-light);
    text-align: left;
}

.nutri-editor-table thead th:last-child {
    text-align: right;
    width: 220px;
}

.nutri-editor-table tbody tr {
    border-bottom: 1px solid var(--color-border-light);
}

.nutri-editor-table tbody tr:hover {
    background: var(--color-cream);
}

.nutri-editor-table tbody td {
    padding: 7px 14px;
    vertical-align: middle;
}

.nutri-editor-table .nutri-sub td {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.nutri-value-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.nutri-input {
    width: 70px;
    padding: 5px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    text-align: right;
    background: var(--color-bg-card);
    color: var(--color-text);
}

.nutri-input:focus {
    outline: none;
    border-color: var(--color-primary-light);
    background: var(--color-bg);
}

.nutri-unit {
    color: var(--color-text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.nutri-sep {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.editor-readonly .nutri-input {
    pointer-events: none;
    opacity: 0.85;
    background: var(--color-bg);
}

/* ===== TABLA VALORES NUTRICIONALES (Sección) ===== */

.nutri-th {
    text-align: right;
    width: 70px;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.nutri-td {
    text-align: right;
    font-size: 0.9rem;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}
