/* ======================================
   SwiftPOS � Root Variables
====================================== */

:root {
    /*--sp-primary: #4F46E5;*/
    --sp-primary: #5B2D8B;
    --sp-primary-soft: #818CF8;
    --sp-secondary: #22C55E;

    --sp-bg-body: #F3F4F6;
    --sp-surface: #FFFFFF;
    --sp-surface-soft: #F9FAFB;
    --sp-border-subtle: #E5E7EB;

    --sp-text-main: #111827;
    --sp-text-muted: #6B7280;

    --sp-success: #16A34A;
    --sp-danger: #DC2626;
    --sp-warning: #FACC15;
    --sp-info: #3B82F6;

    --sp-radius-lg: 18px;
    --sp-radius-md: 12px;
    --sp-radius-pill: 999px;

    --sp-shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.12);

    /* Sidebar colors */
    --sp-bg-soft: #020617;
    --sp-text-inverse: #F9FAFB;
}

/* ======================================
   Global Resets + Fixes
====================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
}

body.swiftpos-body {
    font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--sp-bg-body);
    color: var(--sp-text-main);
}

/* ======================================
   Layout Structure
====================================== */

.swiftpos-app {
    min-height: 100vh;
    display: flex;
}

/* FIX: prevent overflow on mobile caused by flex */
@media (max-width: 991.98px) {
    .swiftpos-app {
        display: block !important;
    }
}

.swiftpos-main {
    flex: 1 1 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--sp-surface-soft);
    color: var(--sp-text-main);

    /* FIX */
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
}

.swiftpos-content {
    padding: 1rem;
    max-width: 100% !important;
    box-sizing: border-box;
    overflow-x: hidden !important;
}

/* ======================================
   Topbar
====================================== */

.swiftpos-topbar {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 0.98rem;
    font-weight: 600;
}

/* ======================================
   Footer
====================================== */

.swiftpos-footer {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--sp-text-muted);
}

/* ===========================================================
   SWIFTPOS � PERFECT SIDEBAR (FULL REWRITE)
   Mobile + Desktop stable version
=========================================================== */

/* ==== SIDEBAR BASE ==== */
.swiftpos-sidebar {
    background:
        /*radial-gradient(circle at top, rgba(79, 70, 229, 0.35), transparent 55%),*/
        radial-gradient(circle at top, rgba(91, 45, 139, 0.9) 0%,
            rgba(91, 45, 139, 0.4) 50%,
            transparent 100%)
        var(--sp-bg-soft);
    color: var(--sp-text-inverse);

    display: flex;
    flex-direction: column;

    padding: 0.75rem 0.5rem;

    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    border-right: 1px solid rgba(15, 23, 42, 0.85);

    z-index: 1030;

    /* ANIMATION */
    transition:
        width 0.25s ease,
        transform 0.30s ease,
        opacity 0.25s ease;
}

/* Prevent page shifting */
.swiftpos-sidebar * {
    box-sizing: border-box;
}

/* ===========================================================
   DESKTOP MODE
=========================================================== */
@media (min-width: 992px) {

    /* Normal desktop sidebar (expanded) */
    .swiftpos-sidebar {
        position: sticky;
        top: 0;
        width: 260px;
        transform: translateX(0); /* always open */
    }

    /* Collapsed sidebar (desktop only) */
    .swiftpos-sidebar.collapsed {
        width: 78px;
    }

    /* Hide labels on collapsed */
    .swiftpos-sidebar.collapsed .brand-text,
    .swiftpos-sidebar.collapsed .sidebar-section-label,
    .swiftpos-sidebar.collapsed .sidebar-link .label,
    .swiftpos-sidebar.collapsed .sidebar-user .user-meta {
        display: none !important;
    }

    /* Icon centering when collapsed */
    .swiftpos-sidebar.collapsed .sidebar-link {
        justify-content: center;
        padding-inline: 0.5rem !important;
    }
}

/* ===========================================================
   MOBILE MODE (OFF-CANVAS)
=========================================================== */
@media (max-width: 991.98px) {

    .swiftpos-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;

        width: 260px;
        max-width: 80%;

        /* START HIDDEN */
        transform: translateX(-100%);
        opacity: 0;

        box-shadow: 10px 0 28px rgba(0, 0, 0, 0.4);
    }

    /* When mobile menu is open */
    body.sidebar-mobile-open .swiftpos-sidebar {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===========================================================
   MOBILE OVERLAY DARK BACKGROUND
=========================================================== */
.swiftpos-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;

    z-index: 1020;

    transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* Show overlay only when sidebar is open */
body.sidebar-mobile-open .swiftpos-overlay {
    opacity: 1;
    visibility: visible;
}

/* Hide completely on desktop */
@media (min-width: 992px) {
    .swiftpos-overlay {
        display: none !important;
    }
}

/* ===========================================================
   SIDEBAR INNER ELEMENTS (Stable UI)
=========================================================== */

.sidebar-header {
    padding: 0.4rem 0.6rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--sp-primary), #0EA5E9);
    color: white;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.brand-subtitle {
    font-size: 0.7rem;
    opacity: 0.75;
}

/* User info */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem 0.25rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-meta {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 500;
}

.user-role {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* Section labels */
.sidebar-section-label {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 0.8rem 1rem 0.4rem;
    color: rgba(148, 163, 184, 0.9);
}

/* Nav links */
.sidebar-nav {
    margin-top: 0.4rem;
    padding-bottom: 1rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;

    padding: 0.45rem 0.9rem;
    border-radius: var(--sp-radius-pill);

    color: #E5E7EB;
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;

    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-1px);
}

.sidebar-link.active {
    background: linear-gradient(90deg, var(--sp-primary), #0EA5E9);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 0.7rem 0.9rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.logout-link {
    color: #FCA5A5;
}



/* ======================================
   Cards
====================================== */

.card {
    background: var(--sp-surface);
    border-radius: var(--sp-radius-lg);
    border: 1px solid var(--sp-border-subtle);
    box-shadow: var(--sp-shadow-soft);
    margin-bottom: 1rem;
}

.card-header {
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 0.75rem 1rem;
}

.card-body {
    padding: 1rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
}

/* Metric-style cards */

.metric-card {
    border-radius: var(--sp-radius-lg);
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: #ffffff;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
    padding: 1rem 1.1rem;
}

.metric-card-title {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--sp-text-muted);
}

.metric-card-value {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.metric-card-sub {
    font-size: 0.75rem;
    color: var(--sp-text-muted);
}

.metric-icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* ======================================
   Buttons
====================================== */

.btn {
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--sp-radius-pill);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
}

.btn-primary {
    background-color: var(--sp-primary);
    border-color: var(--sp-primary);
    color: white;
}

.btn-primary:hover {
    background-color: #4338ca;
    border-color: #4338ca;
}

/* ======================================
   Forms
====================================== */

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--sp-text-main);
}

.form-control,
.form-select,
textarea.form-control {
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 0.85rem;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
    border-color: var(--sp-primary-soft);
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.55);
}

/* ======================================
   RESPONSIVE TABLE (FIXED + WORKING)
====================================== */

.sp-table-container {
    width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.sp-table-container table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.sp-table-container th,
.sp-table-container td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
    font-size: 0.82rem;
}

.sp-table-container thead th {
    background: #f9fafb;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 2;
}

.sp-table-container tbody tr:nth-child(even) {
    background: #f3f4f6;
}

.sp-table-container tbody tr:hover {
    background: #eef2ff;
}

@media (max-width: 575.98px) {
    .sp-table-container table {
        min-width: 700px !important;
    }
    .sp-table-container th,
    .sp-table-container td {
        padding: 0.65rem 0.75rem;
        font-size: 0.78rem;
    }
}

/* ======================================
   Badges & Status Chips
====================================== */

.badge {
    border-radius: 999px;
    padding: 0.25em 0.55em;
    font-size: 0.7rem;
}

.bg-success-subtle {
    background-color: rgba(22, 163, 74, 0.14) !important;
    color: #166534 !important;
}

.bg-danger-subtle {
    background-color: rgba(220, 38, 38, 0.14) !important;
    color: #991b1b !important;
}

.bg-info-subtle {
    background-color: rgba(59, 130, 246, 0.14) !important;
    color: #1d4ed8 !important;
}

/* ======================================
   Animations (Original untouched)
====================================== */

.card.sp-animate-card,
.metric-card.sp-animate-card {
    position: relative;
    opacity: 0;
    transform: translateY(12px) scale(0.985);
    transition:
        opacity 0.45s ease-out,
        transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
        box-shadow 0.25s ease-out,
        border-color 0.25s ease-out,
        background-color 0.25s ease-out;
    will-change: opacity, transform;
}

.card.sp-animate-card.sp-animate-visible,
.metric-card.sp-animate-card.sp-animate-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Hover effect */
.card.sp-animate-card:hover,
.metric-card.sp-animate-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.18);
    border-color: rgba(79, 70, 229, 0.22);
    background-color: var(--sp-surface-soft);
}

/* Header sheen */
.card.sp-animate-card .card-header,
.metric-card.sp-animate-card .card-header {
    background: linear-gradient(
        120deg,
        rgba(79, 70, 229, 0.06),
        rgba(79, 70, 229, 0.00),
        rgba(79, 70, 229, 0.10)
    );
    background-size: 220% 100%;
    animation: sp-card-header-sheen 9s linear infinite;
}

@keyframes sp-card-header-sheen {
    0% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Fade-in for sections */
.swiftpos-content.sp-animate-section {
    opacity: 0;
    transform: translateY(6px);
    transition:
        opacity 0.4s ease-out,
        transform 0.4s ease-out;
}

.swiftpos-content.sp-animate-section.sp-animate-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Reduced motion fix */
@media (prefers-reduced-motion: reduce) {
    .card.sp-animate-card,
    .metric-card.sp-animate-card,
    .swiftpos-content.sp-animate-section {
        transition: none !important;
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ═══════════════════════════════════════════════════
   SWIFTPOS GLOBAL TOAST SYSTEM
   ═══════════════════════════════════════════════════ */
.swiftpos-toast-container {
    position: fixed;
    top: 1.2rem;
    right: 1.2rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    max-width: 360px;
}

.swiftpos-toast {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 1.1rem;
    border-radius: 14px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    backdrop-filter: blur(8px);
    animation: toast-in 0.3s cubic-bezier(0.175,0.885,0.32,1.275) forwards;
    cursor: pointer;
    min-width: 280px;
}

.swiftpos-toast .toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.swiftpos-toast .toast-text {
    flex: 1;
    line-height: 1.4;
}

/* Success */
.swiftpos-toast-success {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    border-left: 4px solid rgba(255,255,255,0.4);
}

/* Error / danger */
.swiftpos-toast-error,
.swiftpos-toast-danger {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    border-left: 4px solid rgba(255,255,255,0.4);
}

/* Warning */
.swiftpos-toast-warning {
    background: linear-gradient(135deg, #f39c12, #f7ca18);
    color: #1a1a1a;
    border-left: 4px solid rgba(0,0,0,0.15);
}
.swiftpos-toast-warning .toast-icon,
.swiftpos-toast-warning .toast-text {
    color: #1a1a1a;
}

/* Info */
.swiftpos-toast-info,
.swiftpos-toast- {
    background: linear-gradient(135deg, #2980b9, #6dd5fa);
    border-left: 4px solid rgba(255,255,255,0.4);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(60px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(60px) scale(0.9); }
}

/* ═══════════════════════════════════════════════════
   SWIFTPOS TOP NAVIGATION (Desktop lg+)
   ═══════════════════════════════════════════════════ */
.sp-topnav {
    display: none;
    background: var(--sp-surface, #fff);
    border-bottom: 1px solid var(--sp-border, #e5e7eb);
    padding: 0 1.5rem;
    gap: 0;
    position: sticky;
    top: 0;
    z-index: 990;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

@media (min-width: 992px) {
    .sp-topnav {
        display: flex;
        align-items: stretch;
    }
    /* Hide sidebar on desktop when top-nav is active */
    body.sp-topnav-mode #swiftposSidebar {
        display: none !important;
    }
    body.sp-topnav-mode .swiftpos-main {
        margin-left: 0 !important;
    }
}

.sp-topnav-item {
    position: relative;
    display: flex;
    align-items: center;
}

.sp-topnav-link {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.85rem 1.1rem;
    color: var(--sp-text-muted, #6b7280);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: all 0.18s ease;
    cursor: pointer;
    border-top: none;
    border-left: none;
    border-right: none;
    background: none;
}

.sp-topnav-link:hover,
.sp-topnav-link.active {
    color: #7c3aed;
    border-bottom-color: #7c3aed;
    background: #f3f0ff;
    border-radius: 6px;
}

/* Dropdown panel */
.sp-topnav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 215px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    z-index: 1000;
    padding: 0.4rem;
}

.sp-topnav-item:hover .sp-topnav-dropdown,
.sp-topnav-item:focus-within .sp-topnav-dropdown {
    display: block;
    animation: sp-drop-in 0.15s ease;
}

@keyframes sp-drop-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.sp-topnav-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.81rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.12s, color 0.12s;
}

.sp-topnav-dropdown a:hover {
    background: #f3f0ff;
    color: #7c3aed;
}

.sp-topnav-dropdown .sp-nav-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sp-text-muted, #9ca3af);
    padding: 0.6rem 1.2rem 0.2rem;
}

.sp-topnav-dropdown .sp-lock-item {
    opacity: 0.55;
    cursor: not-allowed;
}
.sp-topnav-dropdown .sp-lock-item:hover {
    background: none;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE NAV — Desktop: top-nav only (no sidebar)
                  — Mobile:  sidebar only (no top-nav)
   ═══════════════════════════════════════════════════ */

/* Desktop (lg = 992px+): hide sidebar, show top-nav */
@media (min-width: 992px) {
    #swiftposSidebar {
        display: none !important;
    }
    .swiftpos-main {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .sp-topnav {
        display: flex !important;
    }
}

/* Mobile (< 992px): hide top-nav, keep sidebar */
@media (max-width: 991.98px) {
    .sp-topnav {
        display: none !important;
    }
}
