﻿:root {
    --color-bg: #f3f4f6;
    --color-bg-card: #ffffff;
    --color-bg-sidebar: #111827;
    --color-bg-header: #ffffff;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-border: #e5e7eb;
    --color-sidebar-text: #e5e7eb;
    --color-sidebar-text-muted: #9ca3af;
    --color-sidebar-active-bg: #1f2937;
}

/* DARK THEME: solo cambiando variables */
body.theme-dark {
    --color-bg: #020617;
    --color-bg-card: #020617;
    --color-bg-sidebar: #020617;
    --color-bg-header: #020617;
    --color-text: #e5e7eb;
    --color-text-muted: #9ca3af;
    --color-primary: #60a5fa;
    --color-primary-hover: #3b82f6;
    --color-border: #1f2937;
    --color-sidebar-text: #e5e7eb;
    --color-sidebar-text-muted: #6b7280;
    --color-sidebar-active-bg: #111827;
}

/* ---------------- GLOBAL ---------------- */

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
}

/* ---------------- APP SHELL ---------------- */

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 0.2s ease;
}

    /* (Opcional) en desktop, si quieres un sidebar más estrecho cuando se "abra/cierre" */
    .app-shell.sidebar-open {
        grid-template-columns: 70px minmax(0, 1fr);
    }

/* Sidebar */

.app-sidebar {
    background-color: var(--color-bg-sidebar);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0.75rem 1rem;
    box-sizing: border-box;
}

.sidebar-header {
    padding: 0.5rem 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 0.75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.brand-logo {
    font-size: 1.3rem;
}

.brand-text {
    font-size: 1.1rem;
}

.company-name {
    font-size: 0.8rem;
    color: var(--color-sidebar-text-muted);
}

.sidebar-menu {
    flex: 1;
    margin-top: 0.5rem;
}

    .sidebar-menu ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .sidebar-menu a {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.15rem;
        border-radius: 0.45rem;
        text-decoration: none;
        color: var(--color-sidebar-text-muted);
        font-size: 0.92rem;
    }

        .sidebar-menu a:hover {
            background-color: rgba(255, 255, 255, 0.05);
            color: var(--color-sidebar-text);
        }

    .sidebar-menu .icon {
        width: 1.2rem;
        text-align: center;
    }

/* Main */

.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    background-color: var(--color-bg-header);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

    .app-header .left {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .app-header .right {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

.page-title {
    margin: 0;
    font-size: 1.05rem;
}

.app-content {
    padding: 1rem 1.5rem;
    flex: 1;
    box-sizing: border-box;
    background-color: var(--color-bg);
}

.app-footer {
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
}

/* ---------------- BOTONES / LINKS ---------------- */

.btn-icon {
    border: none;
    border-radius: 0.5rem;
    padding: 0.3rem 0.55rem;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
}

    .btn-icon:hover {
        background-color: rgba(148, 163, 184, 0.25);
    }

/* Sobrescribimos Bootstrap btn-primary con nuestros colores */
.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    border-radius: 0.5rem;
    padding: 0.45rem 0.9rem;
    font-weight: 500;
}

    .btn-primary:hover,
    .btn-primary:focus {
        background-color: var(--color-primary-hover);
        border-color: var(--color-primary-hover);
    }

.btn-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 0.9rem;
}

    .btn-link:hover {
        text-decoration: underline;
    }

/* ---------------- FORMULARIOS ---------------- */

.form-group {
    margin-bottom: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-control,
.form-select,
textarea.form-control {
    border-radius: 0.45rem;
    border: 1px solid var(--color-border);
    padding: 0.4rem 0.55rem;
    font-size: 0.95rem;
    background: var(--color-bg-card);
    color: var(--color-text);
}

    .form-control:focus,
    .form-select:focus,
    textarea.form-control:focus {
        outline: none;
        border-color: var(--color-primary);
        box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
    }

.form-check-input {
    width: 1rem;
    height: 1rem;
}

/* ---------------- AUTH CARD ---------------- */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2.5rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background-color: var(--color-bg-card);
    border-radius: 1rem;
    padding: 1.5rem 1.7rem;
    box-shadow: 0 10px 35px rgba(15, 23, 42, 0.15);
    box-sizing: border-box;
}

    .auth-card h2 {
        margin-top: 0;
        margin-bottom: 0.3rem;
    }

.muted {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ---------------- USER INFO ---------------- */

.user-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.9rem;
}

.user-name {
    font-weight: 500;
}

/* ---------------- PAGE HEADER ---------------- */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.page-header-left {
    min-width: 0;
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---------------- INTEGRACIÓN BOOTSTRAP ---------------- */

.card {
    background-color: var(--color-bg-card);
    color: var(--color-text);
    border-color: var(--color-border);
}

.text-muted {
    color: var(--color-text-muted) !important;
}

.badge.bg-light {
    background-color: #e5e7eb !important;
    color: #111827 !important;
    border: 1px solid #d1d5db;
}

body.theme-dark .badge.bg-light {
    background-color: #111827 !important;
    color: var(--color-text) !important;
    border-color: #1f2937 !important;
}

.table {
    color: var(--color-text);
}

    .table thead,
    .table thead.table-light {
        background-color: rgba(148, 163, 184, 0.12);
        border-bottom-color: var(--color-border);
    }

body.theme-dark .table thead,
body.theme-dark .table thead.table-light {
    background-color: #020617;
    border-bottom-color: #1f2937;
}

.table-hover > tbody > tr:hover {
    background-color: rgba(148, 163, 184, 0.12);
}

body.theme-dark .table-hover > tbody > tr:hover {
    background-color: rgba(15, 23, 42, 0.7);
}

body.theme-dark .btn-light {
    background-color: #111827;
    border-color: #1f2937;
    color: var(--color-text);
}

    body.theme-dark .btn-light:hover {
        background-color: #1f2937;
    }

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark textarea.form-control {
    background-color: #020617;
    color: var(--color-text);
    border-color: #1f2937;
}

body.theme-dark ::placeholder {
    color: #6b7280;
}

/* ---------------- RESPONSIVE ---------------- */

@media (max-width: 900px) {
    /* El contenido ocupa TODO el ancho, el sidebar va aparte como overlay */
    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 100;
    }

    /* El JS agrega .sidebar-open al app-shell */
    .app-shell.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-main {
        min-height: 100vh;
    }

    .app-content {
        padding: 0.75rem 0.75rem 1rem;
    }

    .app-header {
        flex-wrap: wrap;
        gap: 0.35rem;
        align-items: flex-start;
    }

        .app-header .left,
        .app-header .right {
            width: 100%;
            justify-content: space-between;
        }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header-right {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

        .page-header-right .btn,
        .page-header-right .btn-group {
            width: 100%;
        }
}

/* ---------------- ACCESS DENIED ---------------- */

.access-denied-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

    .access-denied-page .card {
        max-width: 480px;
        padding: 2rem;
        text-align: center;
    }
