/* ============================================================
   FormuN — styles.css
   Visual language reutilizada del sistema almacen.quitexacolors
   ============================================================ */

/* ── Variables ── */
:root {
    --color-primary:      #1d4ed8;
    --color-primary-dark: #1e40af;
    --color-primary-soft: #dbeafe;
    --color-danger:       #dc2626;
    --color-danger-soft:  #fee2e2;
    --color-success:      #16a34a;
    --color-success-dark: #15803d;
    --color-warning:      #d97706;

    --bg-app:    #f1f5f9;
    --bg-white:  #ffffff;
    --bg-card:   #ffffff;
    --bg-sidebar:#0f172a;

    --text-main:   #1e293b;
    --text-muted:  #64748b;
    --text-light:  #94a3b8;

    --border:     #e2e8f0;
    --radius:     .5rem;
    --radius-sm:  .3rem;
    --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 12px rgba(0,0,0,.1);

    --sidebar-w:  220px;
    --sidebar-w-colapsado: 56px;
    --header-h:   52px;
    --transition: .2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg-app); color: var(--text-main); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ── Layout ── */
.app-frame {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr auto;
    grid-template-areas:
        "sidebar header"
        "sidebar main"
        "sidebar footer";
    min-height: 100vh;
    transition: grid-template-columns var(--transition);
}
.app-frame.sb-colapsado { grid-template-columns: var(--sidebar-w-colapsado) 1fr; }

/* ── Sidebar ── */
.menu-lateral {
    grid-area: sidebar;
    background: var(--bg-sidebar);
    color: #c7d2fe;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: width var(--transition);
    width: var(--sidebar-w);
    z-index: 100;
}
.app-frame.sb-colapsado .menu-lateral { width: var(--sidebar-w-colapsado); }

.sb-marca {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .9rem .8rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    min-height: var(--header-h);
}
.sb-logo-wrap {
    flex-shrink: 0;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(255,255,255,.06);
}
/* Logo como imagen: ocupa el espacio disponible */
.sb-logo-wrap.sb-logo-wrap--con-img {
    flex: 1;
    min-width: 0;
    width: auto;
    height: auto;
    background: transparent;
    border-radius: 0;
    justify-content: center;
    overflow: visible;
}
.sb-logo-img {
    max-height: 38px;
    max-width: 100%;
    object-fit: contain;
    object-position: center center;
    width: auto;
    height: auto;
    filter: brightness(0) invert(1); /* logo blanco sobre fondo oscuro */
}
.sb-logo-ph {
    display: none; /* visible solo cuando el sidebar está colapsado */
    align-items: center; justify-content: center;
    width: 100%; height: 100%;
    background: var(--color-primary);
    font-size: .95rem; font-weight: 700; color: #fff;
    border-radius: var(--radius-sm);
}
.app-frame.sb-colapsado .menu-lateral .sb-logo-ph { display: flex; }
.sb-empresa-nombre {
    font-size: .85rem; font-weight: 700; color: #bfdbfe;
    white-space: nowrap; overflow: hidden;
    transition: opacity var(--transition), width var(--transition);
}
.app-frame.sb-colapsado .sb-empresa-nombre { opacity: 0; width: 0; }
.app-frame.sb-colapsado .sb-toggle-icon { transform: rotate(180deg); }

.sb-toggle-btn {
    margin-left: auto; flex-shrink: 0;
    color: #60a5fa; padding: .25rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
}
.sb-toggle-btn:hover { color: #e0f2fe; }
.sb-toggle-icon { transition: transform var(--transition); }

.menu-lateral nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: .5rem 0; }
.menu-lateral nav ul { display: flex; flex-direction: column; gap: .1rem; }

.menu-lateral nav a {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .8rem;
    border-radius: var(--radius-sm);
    margin: 0 .4rem;
    font-size: .82rem;
    color: #93c5fd;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    overflow: hidden;
}
.menu-lateral nav a:hover { background: rgba(255,255,255,.08); color: #e0f2fe; }
.menu-lateral nav a.activo { background: var(--color-success); color: #fff; }
.menu-lateral nav a.activo:hover { background: var(--color-success-dark); }
.menu-lateral nav a svg { flex-shrink: 0; }

.sb-label { overflow: hidden; transition: opacity var(--transition), width var(--transition); }
.app-frame.sb-colapsado .sb-label { opacity: 0; width: 0; }

.sb-tip {
    display: none;
    position: absolute; left: calc(var(--sidebar-w-colapsado) + 4px);
    background: #0f172a; color: #e0f2fe;
    font-size: .75rem; padding: .25rem .5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    z-index: 200;
}
.app-frame.sb-colapsado .menu-lateral nav a { position: relative; }
.app-frame.sb-colapsado .menu-lateral nav a:hover .sb-tip { display: block; }

.sb-seccion-titulo {
    padding: .7rem .8rem .2rem 1rem;
    font-size: .68rem; text-transform: uppercase;
    letter-spacing: .07em; color: #38bdf8;
    white-space: nowrap; overflow: hidden;
}
.app-frame.sb-colapsado .sb-seccion-titulo { opacity: 0; height: 0; padding: 0; }

/* ── Header ── */
.encabezado {
    grid-area: header;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 90;
    height: var(--header-h);
    display: flex; align-items: center;
}
.encabezado-contenido {
    display: flex; align-items: center; gap: .75rem;
    width: 100%; padding: 0 1.25rem;
}
.encabezado-titulo {
    font-size: .9rem; font-weight: 700; color: var(--text-main);
    flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Hamburguesa (solo móvil) */
.sb-hamburguesa { display: none; color: var(--text-muted); padding: .25rem; border-radius: var(--radius-sm); }

/* Overlay sidebar en móvil */
.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }

/* Usuario dropdown */
.usuario-menu { position: relative; margin-left: auto; }
.usuario-btn {
    display: flex; align-items: center; gap: .4rem;
    padding: .4rem .65rem; border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: .82rem; color: var(--text-main);
    background: var(--bg-white);
    transition: background var(--transition);
}
.usuario-btn:hover { background: #f8fafc; }
.usuario-icono { color: var(--text-muted); }
.usuario-nombre { font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flecha-icono { color: var(--text-light); }

.usuario-dropdown {
    position: absolute; right: 0; top: calc(100% + .4rem);
    min-width: 180px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: .3rem;
    z-index: 110;
}
.usuario-dropdown[hidden] { display: none; }
.dropdown-item {
    display: flex; align-items: center; gap: .5rem;
    width: 100%; padding: .5rem .7rem;
    border-radius: var(--radius-sm);
    font-size: .82rem; color: var(--text-main);
    transition: background var(--transition);
    cursor: pointer;
}
.dropdown-item:hover { background: #f1f5f9; }
.dropdown-item--danger { color: var(--color-danger); }
.dropdown-item--danger:hover { background: var(--color-danger-soft); }

/* ── Main content ── */
.contenido-principal {
    grid-area: main;
    padding: 1.5rem;
    overflow-y: auto;
}
.pie {
    grid-area: footer;
    text-align: center; font-size: .75rem; color: var(--text-light);
    padding: .75rem; border-top: 1px solid var(--border);
    background: var(--bg-white);
}
.pie a { color: var(--color-primary); }

/* ── Page header ── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem; flex-wrap: wrap; gap: .5rem;
}
.page-titulo { font-size: 1.3rem; font-weight: 700; }

/* ── Botones ── */
.boton {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .45rem .9rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: .82rem; font-weight: 500;
    color: var(--text-main); background: var(--bg-white);
    transition: background var(--transition), border-color var(--transition);
    cursor: pointer; white-space: nowrap;
}
.boton:hover { background: #f1f5f9; }
.boton:disabled { opacity: .6; cursor: not-allowed; }
.boton-primario { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.boton-primario:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.boton-peligro { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.boton-peligro:hover { background: #b91c1c; border-color: #b91c1c; }
.boton-sm { padding: .3rem .6rem; font-size: .75rem; }
.boton-full { width: 100%; }

/* ── Inputs ── */
.input-base {
    width: 100%;
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .82rem;
    color: var(--text-main);
    background: var(--bg-white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.input-base:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.input-base--sm { padding: .3rem .55rem; font-size: .78rem; }
textarea.input-base { resize: vertical; }

/* ── Tabla ── */
.tabla-responsive { overflow-x: auto; }
.tabla {
    width: 100%; border-collapse: collapse;
    font-size: .82rem;
    background: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.tabla th, .tabla td {
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.tabla th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.tabla tr:last-child td { border-bottom: none; }
.tabla tr:hover td { background: #fafafa; }
.tabla-compacta th, .tabla-compacta td { padding: .4rem .6rem; }
.tabla-vacio { color: var(--text-light); text-align: center; padding: 2rem; }

/* ── Badge / estado ── */
.badge {
    display: inline-block; padding: .2rem .55rem;
    border-radius: 9999px; font-size: .72rem; font-weight: 600;
}
.badge-verde  { background: #dcfce7; color: #15803d; }
.badge-gris   { background: #f1f5f9; color: #64748b; }
.badge-rojo   { background: var(--color-danger-soft); color: var(--color-danger); }

/* ── Formularios ── */
.formulario-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.formulario-seccion {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.formulario-seccion:last-of-type { border-bottom: none; }
.formulario-seccion-titulo { font-size: .9rem; font-weight: 700; margin-bottom: 1rem; color: var(--text-main); }
.formulario-fila { display: flex; gap: 1rem; flex-wrap: wrap; }
.formulario-grupo { display: flex; flex-direction: column; gap: .3rem; flex: 1; min-width: 160px; }
.formulario-grupo--ancho { flex: 2; }
.formulario-label { font-size: .78rem; font-weight: 600; color: var(--text-muted); }
.formulario-acciones {
    display: flex; gap: .75rem; justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ── Autocomplete ingredientes ── */
.ing-autocomplete {
    position: fixed;
    z-index: 999;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 220px;
    overflow-y: auto;
    min-width: 260px;
}
.ing-autocomplete[hidden] { display: none; }
.ing-ac-item {
    display: flex; flex-direction: column;
    padding: .45rem .75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.ing-ac-item:last-child { border-bottom: none; }
.ing-ac-item:hover,
.ing-ac-item.ing-ac-activo { background: var(--color-primary-soft); }
.ing-ac-nombre { font-size: .82rem; font-weight: 600; color: var(--text-main); }
.ing-ac-meta   { font-size: .73rem; color: var(--text-muted); margin-top: .1rem; }
.ing-ac-vacio  { padding: .6rem .75rem; font-size: .8rem; color: var(--text-muted); text-align: center; }

/* ── Alertas ── */
.alerta {
    padding: .65rem .9rem;
    border-radius: var(--radius);
    font-size: .82rem;
    margin-bottom: .75rem;
}
.alerta[hidden] { display: none; }
.alerta-error   { background: var(--color-danger-soft); color: var(--color-danger); border: 1px solid #fecaca; }
.alerta-exito   { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.texto-alerta   { color: var(--color-danger); font-size: .8rem; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal-caja {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    display: flex; flex-direction: column;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: .95rem; font-weight: 700; }
.modal-cerrar-btn { color: var(--text-light); font-size: 1.1rem; line-height: 1; padding: .2rem .35rem; border-radius: var(--radius-sm); }
.modal-cerrar-btn:hover { background: #f1f5f9; color: var(--text-main); }
.modal-form { padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.modal-footer {
    display: flex; gap: .6rem; justify-content: flex-end;
    padding: .9rem 1.25rem; border-top: 1px solid var(--border);
}

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 380px; padding: 1rem; }
.login-card {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 2.5rem 2rem;
}
.login-logo-wrap {
    display: flex; justify-content: center; margin-bottom: 1rem;
}
.login-logo-text {
    display: flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: var(--radius);
    background: var(--color-primary); color: #fff;
    font-size: 1.6rem; font-weight: 700; letter-spacing: .03em;
}
.login-titulo { text-align: center; font-size: 1.5rem; font-weight: 800; color: var(--color-primary); margin-bottom: .25rem; }
.login-subtitulo { text-align: center; font-size: .78rem; color: var(--text-muted); margin-bottom: 1.75rem; }
.login-form { display: flex; flex-direction: column; gap: .85rem; }

/* ── Tabs ── */
.tabs-wrap {
    display: flex; gap: .25rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}
.tab-btn {
    padding: .55rem 1.1rem;
    font-size: .82rem; font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--color-primary); }
.tab-btn--activo { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-panel { display: block; }
.tab-panel[hidden] { display: none; }

/* ── Config cards ── */
.config-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.config-card-header {
    padding: .9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.config-card-header h2 { font-size: .9rem; font-weight: 700; }
.config-card-body { padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.config-card-footer {
    padding: .9rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end;
}

/* ── Logo upload ── */
.logo-upload-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo-preview-wrap {
    width: 200px; height: 90px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    background: #f8fafc;
    overflow: hidden;
}
.logo-preview-ph { font-size: .78rem; color: var(--text-light); }

/* ── Divider ── */
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: .3rem 0; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .app-frame { grid-template-columns: 0 1fr; grid-template-areas: "header header" "main main" "footer footer"; }
    .menu-lateral { position: fixed; left: -var(--sidebar-w); width: var(--sidebar-w); top: 0; height: 100%; transform: translateX(-100%); transition: transform var(--transition); z-index: 101; }
    .app-frame.sb-abierto .menu-lateral { transform: translateX(0); }
    .app-frame.sb-abierto .sb-overlay { display: block; }
    .sb-hamburguesa { display: flex; }
    .encabezado-titulo { display: none; }
}
