@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #94a3b8;
    --success-color: #10b981;
    --info-color: #06b6d4;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1e293b;
    --sidebar-bg: #1e293b;
    --sidebar-gradient: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-blur: blur(10px);
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #f1f5f9;
    color: #334155;
    overflow-x: hidden;
}

/* Sidebar Styling */
#wrapper {
    display: flex;
}

#sidebar-wrapper {
    min-height: 100vh;
    width: 250px;
    background: var(--sidebar-bg);
    background-image: var(--sidebar-gradient);
    transition: margin 0.25s ease-out;
}

#sidebar-wrapper .sidebar-heading {
    padding: 1.5rem 1.25rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#sidebar-wrapper .list-group-item {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    padding: 1rem 1.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

#sidebar-wrapper .list-group-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

#sidebar-wrapper .list-group-item.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

#sidebar-wrapper .list-group-item i {
    margin-right: 0.75rem;
    width: 1.25rem;
    text-align: center;
}

/* Main Content */
#page-content-wrapper {
    flex: 1;
    overflow-x: hidden;
}

.top-navbar {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Cards */
.card {
    border: none;
    border-radius: 1rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 700;
    color: var(--primary-color);
    padding: 1.25rem;
}

.border-left-primary { border-left: 0.25rem solid var(--primary-color) !important; }
.border-left-success { border-left: 0.25rem solid var(--success-color) !important; }
.border-left-info { border-left: 0.25rem solid var(--info-color) !important; }
.border-left-warning { border-left: 0.25rem solid var(--warning-color) !important; }

/* Dashboard Stats */
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #5a5c69;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary-color);
    letter-spacing: 0.05rem;
}

/* Tables */
.table th {
    background-color: #f8f9fc;
    color: #4e73df;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
}

/* POS UI */
.pos-container {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: var(--card-shadow);
}

.cart-table-container {
    max-height: 400px;
    overflow-y: auto;
}

.billing-sidebar {
    background: #f8f9fc;
    border-left: 1px solid #e3e6f0;
    padding: 1.5rem;
    border-radius: 0 0.75rem 0.75rem 0;
}

/* Auth Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--sidebar-bg);
    background-image: var(--sidebar-gradient);
}

.login-card {
    border-radius: 1rem;
    overflow: hidden;
    max-width: 900px;
}

.login-image {
    background: #fff url('../PharmaCareLogo.png') center / contain no-repeat;
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar-wrapper {
        margin-left: -250px;
    }
    #wrapper.toggled #sidebar-wrapper {
        margin-left: 0;
    }
}

/* ============ Professional Sidebar Menu ============ */
#sidebar-wrapper {
    width: 272px;
    min-width: 272px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1040;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.25rem 1rem;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.45);
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.08rem;
    line-height: 1.1;
}

.brand-text span { color: #a5b4fc; font-weight: 800; }
.brand-sub {
    display: block;
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.14rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

/* Outlet context card */
.outlet-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0.9rem 1rem 0;
    padding: 0.6rem 0.75rem;
    border-radius: 0.75rem;
    background: rgba(99, 102, 241, 0.16);
    border: 1px solid rgba(129, 140, 248, 0.35);
}

.outlet-dot {
    width: 9px;
    height: 9px;
    min-width: 9px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

.outlet-meta strong {
    display: block;
    font-size: 0.95rem;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

.outlet-meta small { font-size: 0.8rem; color: rgba(255, 255, 255, 0.6); }

/* Search */
.sidebar-search {
    position: relative;
    margin: 0.9rem 1rem 0.25rem;
}

.sidebar-search i {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
}

.sidebar-search input {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.07);
    border-radius: 0.65rem;
    padding: 0.55rem 0.75rem 0.55rem 2.2rem;
    font-size: 0.95rem;
    color: #fff;
    outline: none;
}

.sidebar-search input::placeholder { color: rgba(255, 255, 255, 0.35); }
.sidebar-search input:focus { border-color: rgba(129, 140, 248, 0.7); background: rgba(255, 255, 255, 0.1); }

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.8rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

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

/* Override legacy list-group look for nav links */
#sidebar-wrapper .list-group-item.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: none;
    border-radius: 0.7rem;
    background: transparent;
    color: rgba(226, 232, 240, 0.78);
    padding: 0.72rem 0.8rem;
    margin: 2px 0;
    font-weight: 600;
    font-size: 1.02rem;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

#sidebar-wrapper .list-group-item.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.09);
    transform: translateX(2px);
}

#sidebar-wrapper .list-group-item.nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.85) 0%, rgba(139, 92, 246, 0.75) 100%);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

#sidebar-wrapper .list-group-item.nav-link.active::before {
    content: "";
    position: absolute;
    left: -0.8rem;
    top: 20%;
    height: 60%;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: #a5b4fc;
}

.nav-ic {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.08);
    color: #c7d2fe;
}

.nav-link.active .nav-ic { background: rgba(255, 255, 255, 0.22); color: #fff; }
.nav-link:hover .nav-ic { background: rgba(255, 255, 255, 0.16); color: #fff; }
#sidebar-wrapper .list-group-item i { margin-right: 0; }

.nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
    font-size: 0.78rem;
    font-weight: 800;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-badge.danger { background: #ef4444; color: #fff; }
.nav-badge.success { background: #10b981; color: #fff; }
.nav-badge.info { background: rgba(129, 140, 248, 0.25); color: #c7d2fe; }

.nav-ic-star { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.nav-link:hover .nav-ic-star, .nav-link.active .nav-ic-star { background: rgba(245, 158, 11, 0.35); color: #fff; }
.nav-badge.pulse { animation: badgePulse 1.8s ease-in-out infinite; }

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* Collapsible groups */
.nav-group { margin-top: 0.9rem; }

.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border: none;
    padding: 0 0.75rem;
    margin-bottom: 0.3rem;
    cursor: pointer;
}

.nav-group-label {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.42);
}

.nav-chev {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.4);
    transition: transform 0.2s ease;
}

.nav-group-toggle[aria-expanded="false"] .nav-chev { transform: rotate(-90deg); }
.nav-group .nav-group-body { display: none; }
.nav-group.open .nav-group-body { display: block; }

.nav-empty { color: rgba(255, 255, 255, 0.5); padding: 1rem 0; }

/* User card */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0.75rem 1rem 1.1rem;
    padding: 0.65rem 0.75rem;
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(165, 180, 252, 0.6); }

.user-meta { flex: 1; min-width: 0; }
.user-meta strong {
    display: block;
    font-size: 0.95rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-meta small { font-size: 0.76rem; color: rgba(255, 255, 255, 0.55); text-transform: uppercase; letter-spacing: 0.08rem; }

.user-logout {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.14);
    text-decoration: none;
    transition: background 0.15s ease;
}

.user-logout:hover { background: rgba(239, 68, 68, 0.3); color: #fff; }

/* Mobile overlay */
#sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1035;
}

/* Desktop: toggle collapses to icon rail */
@media (min-width: 769px) {
    #wrapper.toggled #sidebar-wrapper { width: 88px; min-width: 88px; }
    #wrapper.toggled .brand-text,
    #wrapper.toggled .nav-text,
    #wrapper.toggled .nav-group-label,
    #wrapper.toggled .nav-chev,
    #wrapper.toggled .nav-badge,
    #wrapper.toggled .sidebar-search,
    #wrapper.toggled .outlet-meta,
    #wrapper.toggled .user-meta { display: none; }
    #wrapper.toggled .sidebar-brand { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }
    #wrapper.toggled .nav-group-toggle { justify-content: center; padding: 0; }
    #wrapper.toggled #sidebar-wrapper .list-group-item.nav-link { justify-content: center; }
    #wrapper.toggled .outlet-card { justify-content: center; }
    #wrapper.toggled .outlet-dot { margin: 0; }
    #wrapper.toggled .sidebar-user { justify-content: center; }
}

/* Mobile: off-canvas + overlay */
@media (max-width: 768px) {
    #sidebar-wrapper {
        position: fixed;
        left: 0;
        top: 0;
        width: 272px;
        min-width: 272px;
        margin-left: -272px;
        transition: margin 0.25s ease-out;
    }
    #wrapper.toggled #sidebar-wrapper { margin-left: 0; box-shadow: 20px 0 50px rgba(0, 0, 0, 0.35); }
    #wrapper.toggled #sidebarOverlay { display: block; }
}
