/* ============================================================
   Óptica Masferrer — Layout principal
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

:root {
    --sidebar-width: 260px;
    --sidebar-bg:    #1a2236;
    --sidebar-hover: #243047;
    --sidebar-active:#2d3f63;
    --topbar-height: 60px;
    --primary:       #2563eb;
}

/* ---- Sidebar ---- */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    transition: width .25s ease;
    z-index: 1040;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed {
    width: 0;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,.08);
    gap: .6rem;
}

.sidebar-brand i { font-size: 1.2rem; color: #60a5fa; }

.sidebar-section {
    padding: .9rem 1.25rem .3rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    color: rgba(255,255,255,.35);
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.25rem;
    color: rgba(255,255,255,.72);
    font-size: .9rem;
    white-space: nowrap;
    border-radius: 0;
    transition: background .15s, color .15s;
}

.sidebar-nav .nav-link i {
    width: 18px;
    text-align: center;
    font-size: .95rem;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left: 3px solid #60a5fa;
}

/* ---- Page content ---- */
#content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
    background: #f0f4f8;
    overflow-x: hidden;
}

#content.expanded {
    margin-left: 0;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: 1rem;
}

.topbar .btn-toggle {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.15rem;
    padding: .3rem .5rem;
    line-height: 1;
    border-radius: .375rem;
    cursor: pointer;
    transition: background .15s;
}

.topbar .btn-toggle:hover { background: #f1f5f9; color: #1e293b; }

.topbar .page-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.user-avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
}

/* ---- Content area ---- */
.content-area {
    padding: 1.75rem;
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

/* ---- Cards ---- */
.stat-card {
    border: none;
    border-radius: .75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
}

.stat-card .icon-box {
    width: 52px; height: 52px;
    border-radius: .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

/* ---- Tables ---- */
.table-card {
    border: none;
    border-radius: .75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
    overflow: hidden;
}

.table-card .table { margin: 0; }

.table-card .table thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    padding: .9rem 1rem;
}

.table-card .table tbody td { padding: .85rem 1rem; vertical-align: middle; }
.table-card .table tbody tr:hover { background: #f8fafc; }

/* ---- Login ---- */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2236 0%, #2d3f63 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
    width: 64px; height: 64px;
    background: var(--primary);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin: 0 auto 1.25rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    #sidebar {
        width: 0;
        box-shadow: none;
    }
    #sidebar.open {
        width: var(--sidebar-width);
        box-shadow: 4px 0 24px rgba(0,0,0,.35);
    }
    #content {
        margin-left: 0 !important;
    }
    .content-area {
        padding: 1rem;
    }
    #sidebarOverlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1039;
    }
    #sidebarOverlay.visible { display: block; }

    /* Ocultar columnas secundarias en tablas pequeñas */
    .table-hide-mobile { display: none !important; }
}

@media (max-width: 480px) {
    .content-area { padding: .75rem; }
    .topbar { padding: 0 .75rem; }
    h4.fw-bold { font-size: 1.1rem; }
}
