/* ==========================================================================
   Sistema POS Profesional — Master Stylesheet
   Layout: Sidebar + Topbar + Content
   ========================================================================== */

/* ── CSS Custom Properties ── */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --topbar-height: 60px;
    --sidebar-bg: #1e2235;
    --sidebar-hover: #272b40;
    --sidebar-active: #2c3352;
    --sidebar-text: #8a8fa8;
    --sidebar-text-hover: #ffffff;
    --sidebar-brand-bg: #171a2b;
    --pos-primary: #4361ee;
    --pos-primary-dark: #3a56d4;
    --pos-primary-light: #eef1ff;
    --pos-secondary: #6c757d;
    --pos-success: #2bc155;
    --pos-success-light: #e8faf0;
    --pos-danger: #f35757;
    --pos-danger-light: #fce8e8;
    --pos-warning: #ffab2d;
    --pos-warning-light: #fff5e6;
    --pos-info: #2f80ed;
    --pos-info-light: #e8f1fd;
    --pos-body-bg: #f5f7fb;
    --pos-card-bg: #ffffff;
    --pos-text: #2a2f3b;
    --pos-text-muted: #7c8293;
    --pos-border: #e8ecf1;
    --pos-radius: 12px;
    --pos-radius-sm: 8px;
    --pos-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --pos-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --pos-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--pos-body-bg);
    color: var(--pos-text);
    min-height: 100vh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.pos-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--pos-transition);
    overflow: hidden;
}

/* ── Brand / Logo ── */
.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: var(--sidebar-brand-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    gap: 12px;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--pos-primary);
    flex-shrink: 0;
}

.sidebar-brand .brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 1rem;
    color: #ffffff;
    white-space: nowrap;
    letter-spacing: -0.02em;
}

/* ── Navigation ── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-label {
    padding: 16px 20px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(138, 143, 168, 0.6);
    white-space: nowrap;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid rgba(138, 143, 168, 0.15);
    margin: 6px 20px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--pos-transition);
    gap: 12px;
    position: relative;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.menu-link i:first-child {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.menu-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-hover);
    border-left-color: rgba(67, 97, 238, 0.3);
}

.menu-link.active {
    color: #ffffff;
    background: var(--sidebar-active);
    border-left-color: var(--pos-primary);
}

.menu-link.active i:first-child {
    color: var(--pos-primary);
}

/* ── Submenu toggle arrow ── */
.menu-arrow {
    font-size: 0.7rem;
    margin-left: auto;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.menu-link[aria-expanded="true"] .menu-arrow {
    transform: rotate(180deg);
}

/* ── Submenu items ── */
.menu-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.12);
}

.submenu-link {
    display: flex;
    align-items: center;
    padding: 8px 20px 8px 56px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 400;
    transition: var(--pos-transition);
    gap: 10px;
    white-space: nowrap;
}

.submenu-link i {
    font-size: 0.8rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.7;
}

.submenu-link:hover {
    color: var(--sidebar-text-hover);
    background: rgba(255, 255, 255, 0.04);
}

.submenu-link.active {
    color: var(--pos-primary);
}

/* ── Sidebar Footer (user) ── */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 14px 20px;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--pos-primary), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: var(--sidebar-text);
    font-size: 0.72rem;
}

/* ==========================================================================
   MAIN WRAPPER
   ========================================================================== */
.pos-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--pos-transition);
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.pos-topbar {
    height: var(--topbar-height);
    background: var(--pos-card-bg);
    border-bottom: 1px solid var(--pos-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: var(--pos-radius-sm);
    color: var(--pos-text);
    font-size: 1.3rem;
    padding: 0;
    transition: var(--pos-transition);
}

.sidebar-toggle:hover {
    background: var(--pos-body-bg);
    color: var(--pos-primary);
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--pos-text);
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--pos-text);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: var(--pos-radius-sm);
    transition: var(--pos-transition);
}

.topbar-user:hover {
    background: var(--pos-body-bg);
    color: var(--pos-text);
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--pos-primary), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
}

/* ── Topbar dropdown ── */
.topbar-right .dropdown-menu {
    border: 1px solid var(--pos-border);
    box-shadow: var(--pos-shadow-lg);
    border-radius: var(--pos-radius);
    padding: 8px;
    min-width: 200px;
    margin-top: 8px;
}

.topbar-right .dropdown-item {
    border-radius: var(--pos-radius-sm);
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--pos-transition);
}

.topbar-right .dropdown-item:hover {
    background: var(--pos-primary-light);
    color: var(--pos-primary);
}

.topbar-right .dropdown-item i {
    width: 20px;
}

.topbar-right .dropdown-divider {
    margin: 4px 0;
}

/* ==========================================================================
   CONTENT AREA
   ========================================================================== */
.pos-content {
    flex: 1;
    padding: 24px;
}

/* ==========================================================================
   FLASH MESSAGES
   ========================================================================== */
.pos-messages {
    padding: 16px 24px 0;
}

.pos-messages .alert {
    border: none;
    border-radius: var(--pos-radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--pos-shadow);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.pos-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--pos-text-muted);
    border-top: 1px solid var(--pos-border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px 24px;
    flex-wrap: wrap;
}

/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
    border: 1px solid var(--pos-border);
    border-radius: var(--pos-radius);
    box-shadow: var(--pos-shadow);
    background: var(--pos-card-bg);
    transition: var(--pos-transition);
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.card-header {
    background: transparent;
    color: var(--pos-text);
    border-bottom: 1px solid var(--pos-border);
    border-radius: var(--pos-radius) var(--pos-radius) 0 0 !important;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 16px 20px;
}

.card-header i {
    color: var(--pos-primary);
    margin-right: 8px;
}

.card-body {
    padding: 20px;
}

/* ── Stat Cards (Dashboard) ── */
.stat-card {
    border: 1px solid var(--pos-border);
    border-radius: var(--pos-radius);
    background: var(--pos-card-bg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: var(--pos-transition);
    box-shadow: var(--pos-shadow);
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon-blue   { background: var(--pos-info-light); color: var(--pos-info); }
.stat-icon-green  { background: var(--pos-success-light); color: var(--pos-success); }
.stat-icon-orange { background: var(--pos-warning-light); color: var(--pos-warning); }
.stat-icon-red    { background: var(--pos-danger-light); color: var(--pos-danger); }

.stat-info h6 {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--pos-text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-info .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pos-text);
    line-height: 1.2;
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table {
    margin: 0;
    font-size: 0.875rem;
}

.table thead th {
    background: var(--pos-body-bg);
    color: var(--pos-text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--pos-border);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--pos-border);
    color: var(--pos-text);
}

.table tbody tr:hover {
    background: rgba(67, 97, 238, 0.03);
}

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

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn-pos {
    background: var(--pos-primary);
    color: white;
    border: none;
    border-radius: var(--pos-radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 10px 20px;
    transition: var(--pos-transition);
}

.btn-pos:hover {
    background: var(--pos-primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.35);
}

.btn-pos:active {
    transform: translateY(0);
}

.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--pos-radius-sm);
    transition: var(--pos-transition);
}

/* ==========================================================================
   FORMS
   ========================================================================== */
.form-control,
.form-select {
    border: 1.5px solid var(--pos-border);
    border-radius: var(--pos-radius-sm);
    font-size: 0.875rem;
    padding: 10px 14px;
    color: var(--pos-text);
    transition: var(--pos-transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--pos-primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--pos-text);
    margin-bottom: 6px;
}

.form-text,
.form-control + small {
    font-size: 0.78rem;
    color: var(--pos-text-muted);
}

.input-group-text {
    background: var(--pos-body-bg);
    border: 1.5px solid var(--pos-border);
    border-radius: var(--pos-radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--pos-text-muted);
}

/* ==========================================================================
   PAGE HEADER
   ========================================================================== */
.page-title {
    color: var(--pos-text);
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.page-title i {
    color: var(--pos-primary);
}

.text-pos-primary {
    color: var(--pos-primary) !important;
}

/* ==========================================================================
   BADGES
   ========================================================================== */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.badge-activo,
.bg-success {
    background: var(--pos-success) !important;
}

.badge-inactivo {
    background: var(--pos-danger) !important;
}

/* ── Card footer ── */
.card-footer {
    background: transparent;
    border-top: 1px solid var(--pos-border);
    padding: 12px 20px;
}

/* ── List group flush inside cards ── */
.card .list-group-flush .list-group-item {
    border-color: var(--pos-border);
    padding: 12px 20px;
}

.card .list-group-flush .list-group-item:hover {
    background: rgba(67, 97, 238, 0.03);
}

/* ── Modal improvements ── */
.modal-content {
    border: none;
    border-radius: var(--pos-radius);
    box-shadow: var(--pos-shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--pos-border);
    padding: 16px 20px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid var(--pos-border);
    padding: 12px 20px;
}

/* ── Alert improvements ── */
.alert {
    border-radius: var(--pos-radius-sm);
    font-size: 0.875rem;
    border: none;
}

/* ── Dropdown menu ── */
.dropdown-menu {
    border: 1px solid var(--pos-border);
    box-shadow: var(--pos-shadow-lg);
    border-radius: var(--pos-radius);
    padding: 6px;
    font-size: 0.875rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: 8px 12px;
    transition: var(--pos-transition);
}

.dropdown-item:hover {
    background: var(--pos-primary-light);
}

/* ==========================================================================
   UTILITIES
   ========================================================================== */
.icon-xl { font-size: 4rem; }
.icon-lg { font-size: 3rem; }
.icon-md { font-size: 2rem; }

.list-scroll {
    max-height: 400px;
    overflow-y: auto;
}

/* Reports rows */
.bajo-minimo { background-color: var(--pos-warning-light) !important; }
.sin-stock   { background-color: var(--pos-danger-light) !important; }

/* Loading state */
.btn-loading {
    pointer-events: none;
    opacity: 0.7;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--pos-primary);
    color: white;
    padding: 8px 16px;
    z-index: 9999;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
    color: white;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--pos-text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.empty-state small {
    font-size: 0.82rem;
    opacity: 0.8;
}

/* ── Quick actions ── */
.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1.5px solid var(--pos-border);
    border-radius: var(--pos-radius-sm);
    color: var(--pos-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--pos-transition);
}

.quick-action:hover {
    border-color: var(--pos-primary);
    background: var(--pos-primary-light);
    color: var(--pos-primary);
    transform: translateX(4px);
}

.quick-action i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: var(--pos-primary);
}

/* ==========================================================================
   MOBILE RESPONSIVE
   ========================================================================== */
@media (max-width: 991.98px) {
    .pos-sidebar {
        transform: translateX(-100%);
    }

    .pos-sidebar.show {
        transform: translateX(0);
    }

    .pos-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1035;
        opacity: 0;
        visibility: hidden;
        transition: var(--pos-transition);
    }

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    .pos-content {
        padding: 16px;
    }
}

@media (max-width: 575.98px) {
    .pos-topbar {
        padding: 0 16px;
    }

    .topbar-title {
        font-size: 0.95rem;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-info .stat-value {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   PRINT
   ========================================================================== */
@media print {
    .pos-sidebar,
    .pos-topbar,
    .pos-footer,
    .pos-messages {
        display: none !important;
    }

    .pos-main {
        margin-left: 0 !important;
    }

    .pos-content {
        padding: 0 !important;
    }
}
