/* Modern Variables
 * Paleta terracota de la marca Distrilatina (2026-10-16; antes índigo #4f46e5).
 * --primary es algo más oscuro que el terracota del logo (#b0643c) para que el
 * texto blanco de botones y cabecera se lea bien. Ninguna página escribe estos
 * colores a mano: usa las variables. */
:root {
    --primary: #a0552f;
    --primary-hover: #8a4626;
    --primary-light: #b0643c;
    --primary-soft: #f6e7dd;
    --primary-softer: #fbf3ed;
    --primary-ring: #f0d2c0;
    --brand-cream: #f7f2e8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    min-height: 100vh;
    padding: 1rem;
    line-height: 1.5;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Header
 * Color de borde a borde, contenido dentro de 1200 px: el relleno lateral crece
 * con la pantalla. Dentro de un .app-container estrecho queda en 1.5rem. */
.app-header {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-light) 100%);
    padding: 0.9rem max(1.5rem, calc((100% - 1200px) / 2));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* Logo de Distrilatina delante de la marca, en todas las cabeceras del portal
 * (las páginas solo ponen su emoji y su título). */
.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.header-brand::before {
    content: "";
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #fff url('../logo-d.png') center / 34px no-repeat;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.15);
}

.brand-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.brand-subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    color: white;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chip {
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
}

.item-name {
    font-size: 0.875rem;
    color: var(--text-main);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    flex: 1;
    cursor: pointer;
}

/* Alerts */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    background: white;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

/* Responsive */
@media (max-width: 640px) {

    .app-container {
        border-radius: 0;
        min-height: 100vh;
    }

    /* Cabecera en el móvil: sin el correo del usuario (queda el rol y Salir) */
    .app-header .username .user-name {
        display: none;
    }
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* Data Table */
.table-responsive {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0;
}

.pagination-controls {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    background: #f8fafc;
}

.pagination-controls button {
    background: white;
    border: 1px solid var(--border);
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
