/* ============================================
   Vouchify Customer Portal - Design System
   Royal Blue Dark Theme + Collapsible Sidebar
   ============================================ */

/* --- CSS Variables --- */
:root {
    /* Brand Colors */
    --royal-blue: #4169E1;
    --royal-blue-dark: #3457b2;
    --royal-blue-light: #5a7fe8;
    --accent-gold: #FFD700;

    /* Dark Theme */
    --dark-bg: #0a0e1a;
    --card-bg: #111827;
    --card-bg-light: #1f2937;
    --text-light: #f3f4f6;
    --text-muted: #c0c7d0;

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #8b5cf6;

    /* Gradients */
    --gradient-royal: linear-gradient(135deg, #4169E1 0%, #6366f1 50%, #8b5cf6 100%);

    /* Layout Dimensions */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 64px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Spacing Scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
}

/* --- Reset & Base --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Poppins', sans-serif;
    background: var(--dark-bg);
    min-height: 100vh;
    color: var(--text-light);
    background-image:
        radial-gradient(at 0% 0%, rgba(65, 105, 225, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
}

/* Bootstrap Dark Theme Overrides - ensure text is visible on dark bg */
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-muted) !important; }
.opacity-75 { opacity: 0.85 !important; }
.form-label { color: var(--text-light); }
.form-check-label { color: var(--text-light); }
.form-text, .form-control::placeholder { color: var(--text-muted); }
small, .small { color: inherit; }
a.text-primary, .text-primary { color: var(--royal-blue) !important; }
a { color: var(--royal-blue); }
p { color: var(--text-light); }
h1, h2, h3, h4, h5, h6 { color: var(--text-light); }
label { color: var(--text-light); }
td, th { color: var(--text-light); }
.table { color: var(--text-light); }
.table > :not(caption) > * > * { color: inherit; background-color: transparent; }
.alert-info { background: rgba(65, 105, 225, 0.15); border-color: rgba(65, 105, 225, 0.3); color: var(--text-light); }
.alert-danger { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); color: var(--text-light); }
.alert-success { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); color: var(--text-light); }
.alert-warning { background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.3); color: var(--text-light); }
.alert .btn-close { filter: invert(1); }
.badge.bg-light { background: var(--card-bg-light) !important; color: var(--text-light) !important; }
.badge.bg-secondary { background: var(--card-bg-light) !important; color: var(--text-muted) !important; }
.badge.bg-warning { color: #000 !important; }
.form-check-input { background-color: var(--card-bg-light); border-color: rgba(255,255,255,0.2); }
.page-link { color: var(--text-light); background: var(--card-bg-light); border-color: rgba(255,255,255,0.1); }
.page-item.active .page-link { background: var(--royal-blue); border-color: var(--royal-blue); color: white; }
.page-item.disabled .page-link { background: var(--card-bg); color: var(--text-muted); border-color: rgba(255,255,255,0.05); }
.modal-content { background: var(--card-bg); color: var(--text-light); }
.modal-header { border-bottom-color: rgba(255,255,255,0.1); }
.modal-footer { border-top-color: rgba(255,255,255,0.1); }
.modal-title { color: var(--text-light); }
.btn-close { filter: invert(1); }
.dropdown-menu { background: var(--card-bg); border-color: rgba(255,255,255,0.1); }
.dropdown-item { color: var(--text-light); }
.dropdown-item:hover { background: rgba(65, 105, 225, 0.15); color: var(--text-light); }
.list-group-item { background: var(--card-bg-light); color: var(--text-light); border-color: rgba(255,255,255,0.05); }
.card { background: var(--card-bg); color: var(--text-light); border-color: rgba(255,255,255,0.05); }
.nav-link { color: var(--text-muted); }
.nav-link:hover, .nav-link.active { color: var(--text-light); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--dark-bg); }
::-webkit-scrollbar-thumb { background: var(--royal-blue); border-radius: 4px; }


/* ============================================
   SIDEBAR
   ============================================ */

.portal-wrapper {
    display: flex;
    min-height: 100vh;
}

.portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--card-bg);
    border-right: 1px solid rgba(65, 105, 225, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width var(--transition-normal);
    overflow: hidden;
}

/* Sidebar Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 72px;
}

.sidebar-logo img {
    height: 36px;
    max-width: 140px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-logo .nav-label {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--gradient-royal);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(65, 105, 225, 0.3); border-radius: 2px; }

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition-normal);
    cursor: pointer;
    min-height: 44px;
    white-space: nowrap;
}

.sidebar-nav-item iconify-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.sidebar-nav-item:hover {
    color: var(--text-light);
    background: rgba(65, 105, 225, 0.12);
}

.sidebar-nav-item.active {
    background: var(--gradient-royal);
    color: white;
    box-shadow: 0 4px 15px rgba(65, 105, 225, 0.35);
}

.sidebar-nav-item.upgrade-item {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    margin-top: 8px;
}

.sidebar-nav-item.upgrade-item:hover {
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

/* Nav Group (ISP Management collapsible) */
.sidebar-nav-group {
    margin-top: 4px;
}

.sidebar-nav-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: 44px;
    white-space: nowrap;
    user-select: none;
}

.sidebar-nav-group-header:hover {
    color: var(--text-light);
    background: rgba(65, 105, 225, 0.12);
}

.sidebar-nav-group-header.active {
    color: var(--royal-blue-light);
}

.sidebar-nav-group-header .group-chevron {
    margin-left: auto;
    font-size: 1rem;
    transition: transform var(--transition-normal);
}

.sidebar-nav-group.open .group-chevron {
    transform: rotate(180deg);
}

.sidebar-nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav-group.open .sidebar-nav-group-items {
    max-height: 800px;
}

.sidebar-nav-group-items .sidebar-nav-item {
    padding-left: 28px;
    font-size: 0.85rem;
    min-height: 40px;
}

.sidebar-nav-group-items .sidebar-nav-item iconify-icon {
    font-size: 1.1rem;
}

.sidebar-nav-divider {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--royal-blue);
    padding: 12px 28px 4px;
    white-space: nowrap;
}

/* Sidebar User */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 72px;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-logout {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.sidebar-user-logout:hover {
    color: var(--danger);
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: absolute;
    top: 24px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid rgba(65, 105, 225, 0.3);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    z-index: 10;
    font-size: 0.9rem;
}

.sidebar-toggle-btn:hover {
    background: var(--royal-blue);
    color: white;
    border-color: var(--royal-blue);
}

/* Sidebar Collapsed State */
.sidebar-collapsed .portal-sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .sidebar-nav-item {
    justify-content: center;
    padding: 11px 0;
}

.sidebar-collapsed .sidebar-nav-group-header {
    justify-content: center;
    padding: 11px 0;
}

.sidebar-collapsed .sidebar-nav-group-items .sidebar-nav-item {
    padding-left: 0;
}

.sidebar-collapsed .sidebar-nav-divider {
    text-align: center;
    padding: 8px 4px 4px;
    font-size: 0.6rem;
}

.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 20px 12px 16px;
}

.sidebar-collapsed .sidebar-logo img {
    height: 32px;
    max-width: 40px;
}

.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: 16px 12px;
}

.sidebar-collapsed .sidebar-toggle-btn iconify-icon {
    transform: rotate(180deg);
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}


/* ============================================
   TOPBAR
   ============================================ */

.portal-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 900;
    transition: left var(--transition-normal);
}

.sidebar-collapsed .portal-topbar {
    left: var(--sidebar-collapsed-width);
}

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

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

.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.4rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.hamburger-btn:hover {
    background: rgba(65, 105, 225, 0.15);
}


/* ============================================
   MAIN CONTENT
   ============================================ */

.portal-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

.sidebar-collapsed .portal-main {
    margin-left: var(--sidebar-collapsed-width);
}

.portal-content {
    padding: 88px 28px 28px;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Auth pages - no sidebar */
body.auth-page .portal-wrapper { display: block; }
body.auth-page .portal-sidebar,
body.auth-page .portal-topbar,
body.auth-page .sidebar-overlay { display: none; }
body.auth-page .portal-main { margin-left: 0; }
body.auth-page .portal-content { padding: 20px; }


/* ============================================
   BREADCRUMBS
   ============================================ */

.portal-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.portal-breadcrumb li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.portal-breadcrumb li + li::before {
    content: '\203A';
    color: var(--text-muted);
    font-size: 1.1rem;
    opacity: 0.5;
}

.portal-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.portal-breadcrumb a:hover { color: var(--royal-blue-light); }
.portal-breadcrumb .active { color: var(--text-light); font-weight: 500; }


/* ============================================
   CARDS
   ============================================ */

.portal-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 28px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-normal);
}

.portal-card:hover {
    border-color: rgba(65, 105, 225, 0.2);
    box-shadow: 0 8px 32px rgba(65, 105, 225, 0.1);
}

.portal-card-header {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.portal-card-header iconify-icon {
    color: var(--royal-blue);
    font-size: 1.4rem;
}

/* Card Variants */
.portal-card-bordered { border: 1px solid rgba(65, 105, 225, 0.3); }
.portal-card-elevated { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); }
.portal-card-flat { border: none; box-shadow: none; }
.portal-card-interactive { cursor: pointer; }
.portal-card-interactive:hover { transform: translateY(-2px); }


/* ============================================
   STAT CARDS
   ============================================ */

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-royal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(65, 105, 225, 0.2);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 16px;
}

.stat-icon.blue { background: rgba(65, 105, 225, 0.15); color: var(--royal-blue); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.gold { background: rgba(255, 215, 0, 0.15); color: var(--accent-gold); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }

.stat-icon-sm { width: 48px; height: 48px; min-width: 48px; }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}


/* ============================================
   VOUCHER CARDS
   ============================================ */

.voucher-card {
    background: var(--gradient-royal);
    border-radius: var(--radius-xl);
    padding: 28px;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(65, 105, 225, 0.3);
}

.voucher-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 150%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
}

.voucher-card::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -20%;
    width: 60%;
    height: 80%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 50%);
}

.voucher-code {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 3px;
    background: rgba(0, 0, 0, 0.25);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    display: inline-block;
    backdrop-filter: blur(10px);
}


/* ============================================
   CONNECTION CARDS
   ============================================ */

.connection-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 16px;
    transition: all var(--transition-normal);
}

.connection-card:hover {
    border-color: rgba(65, 105, 225, 0.3);
}

.connection-card-active { border-left: 4px solid var(--success); }
.connection-card-paused { border-left: 4px solid var(--warning); }
.connection-card-inactive { border-left: 4px solid var(--text-muted); }

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.active { background: var(--success); box-shadow: 0 0 12px var(--success); }
.status-dot.paused { background: var(--warning); box-shadow: 0 0 12px var(--warning); }
.status-dot.inactive { background: var(--text-muted); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


/* ============================================
   BUTTONS
   ============================================ */

.btn-royal {
    background: var(--gradient-royal);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.btn-royal:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(65, 105, 225, 0.4);
    color: white;
}

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

.btn-royal-outline {
    background: transparent;
    color: var(--royal-blue);
    border: 2px solid var(--royal-blue);
    padding: 10px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.btn-royal-outline:hover {
    background: var(--royal-blue);
    color: white;
}

.btn-pause {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.btn-pause:hover { background: var(--warning); color: white; }

.btn-resume {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.btn-resume:hover { background: var(--success); color: white; }

/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading .btn-text { visibility: hidden; }

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
}

/* Backward compat aliases */
.btn-portal { background: var(--gradient-royal); color: white; border: none; padding: 12px 28px; border-radius: var(--radius-md); font-weight: 600; font-size: 0.95rem; transition: all var(--transition-normal); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.btn-portal:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(65, 105, 225, 0.4); color: white; }


/* ============================================
   FORMS
   ============================================ */

.form-control-royal {
    background: var(--card-bg-light);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-normal);
}

.form-control-royal:focus {
    background: var(--card-bg-light);
    border-color: var(--royal-blue);
    color: white;
    box-shadow: 0 0 0 4px rgba(65, 105, 225, 0.2);
    outline: none;
}

.form-control-royal::placeholder { color: var(--text-muted); }

/* Backward compat alias */
.form-control-portal {
    background: var(--card-bg-light);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-normal);
}
.form-control-portal:focus {
    background: var(--card-bg-light);
    border-color: var(--royal-blue);
    color: white;
    box-shadow: 0 0 0 4px rgba(65, 105, 225, 0.2);
    outline: none;
}
.form-control-portal::placeholder { color: var(--text-muted); }

/* Disabled inputs - keep same background as others (e.g. email on account page) */
.form-control-royal:disabled,
.form-control-portal:disabled {
    background: var(--card-bg-light);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    opacity: 1;
    cursor: not-allowed;
}

/* Validation States */
.form-control-royal.is-invalid,
.form-control-portal.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

.form-control-royal.is-valid,
.form-control-portal.is-valid {
    border-color: var(--success);
}

.invalid-feedback-royal {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 4px;
}

.form-label-royal {
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
}

.form-help-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}


/* ============================================
   STATUS BADGES
   ============================================ */

.status-badge {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-paused { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-pending { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }
.status-expired { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.status-unused { background: rgba(156, 163, 175, 0.2); color: var(--text-muted); }


/* ============================================
   TABLES
   ============================================ */

.table-royal { color: var(--text-light); }

.table-royal thead th {
    background: var(--card-bg-light);
    border-bottom: 2px solid rgba(65, 105, 225, 0.3);
    padding: 14px 16px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.table-royal tbody td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.table-royal tbody tr:hover {
    background: rgba(65, 105, 225, 0.05);
}

/* Zebra striping */
.table-royal tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.table-royal tbody tr:nth-child(even):hover {
    background: rgba(65, 105, 225, 0.05);
}

/* Mobile Card View Tables */
@media (max-width: 768px) {
    .table-responsive-cards thead { display: none; }
    .table-responsive-cards tbody tr {
        display: block;
        margin-bottom: 12px;
        background: var(--card-bg-light);
        border-radius: var(--radius-md);
        padding: 16px;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }
    .table-responsive-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    }
    .table-responsive-cards tbody td:last-child { border-bottom: none; }
    .table-responsive-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.75rem;
        flex-shrink: 0;
        margin-right: 12px;
    }
}


/* ============================================
   ALERTS
   ============================================ */

.alert-royal {
    background: rgba(65, 105, 225, 0.15);
    border: 1px solid rgba(65, 105, 225, 0.3);
    border-radius: var(--radius-md);
    color: var(--text-light);
    padding: 16px 20px;
}

.alert-success-royal {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

.alert-warning-royal {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
}

.alert-danger-royal {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}


/* ============================================
   MODALS (Dark Theme)
   ============================================ */

.modal-royal .modal-content {
    background: var(--card-bg);
    border: 1px solid rgba(65, 105, 225, 0.3);
    border-radius: var(--radius-lg);
    color: var(--text-light);
}

.modal-royal .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px 24px;
}

.modal-royal .modal-body { padding: 24px; }

.modal-royal .modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 16px 24px;
}

.modal-royal .modal-title {
    color: var(--text-light);
    font-weight: 600;
}


/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}


/* ============================================
   PAGINATION
   ============================================ */

.pagination-royal .page-link {
    background: var(--card-bg-light);
    border-color: rgba(65, 105, 225, 0.3);
    color: var(--text-light);
    border-radius: var(--radius-sm);
}

.pagination-royal .page-link:hover {
    background: rgba(65, 105, 225, 0.2);
    color: white;
}

.pagination-royal .page-item.active .page-link {
    background: var(--royal-blue);
    border-color: var(--royal-blue);
    color: white;
}


/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-royal {
    background: var(--card-bg);
    border: 1px solid rgba(65, 105, 225, 0.3);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    min-width: 300px;
    max-width: 420px;
    position: relative;
    overflow: hidden;
}

.toast-icon { font-size: 1.3rem; flex-shrink: 0; }
.toast-icon-success { color: var(--success); }
.toast-icon-error { color: var(--danger); }
.toast-icon-warning { color: var(--warning); }
.toast-icon-info { color: var(--royal-blue); }

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-light);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.toast-close:hover { color: var(--text-light); }

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--royal-blue);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    animation: toastProgress 3s linear forwards;
}

.toast-success .toast-progress { background: var(--success); }
.toast-error .toast-progress { background: var(--danger); }
.toast-warning .toast-progress { background: var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}


/* ============================================
   SKELETON LOADING
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, var(--card-bg-light) 25%, rgba(255,255,255,0.05) 50%, var(--card-bg-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 120px; border-radius: var(--radius-xl); }

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ============================================
   SPINNER
   ============================================ */

.spinner-royal {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Text colors */
.text-muted-portal { color: var(--text-muted); }
.text-royal { color: var(--royal-blue); }

/* Icon colors */
.icon-blue { color: var(--royal-blue); }
.icon-success { color: var(--success); }
.icon-warning { color: var(--warning); }
.icon-gold { color: var(--accent-gold); }
.icon-danger { color: var(--danger); }
.icon-purple { color: #8b5cf6; }

/* Background utilities */
.bg-card-light { background: var(--card-bg-light); }
.bg-gradient-royal { background: var(--gradient-royal); }

/* Icon sizing */
.fs-icon-sm { font-size: 0.8rem; }
.fs-icon-md { font-size: 1.2rem; }
.fs-icon-lg { font-size: 1.5rem; }
.fs-icon-xl { font-size: 3rem; }
.fs-icon-2xl { font-size: 4rem; }
.fs-icon-hero { font-size: 5rem; }

/* Common patterns */
.code-badge {
    background: rgba(65, 105, 225, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--royal-blue-light);
    font-family: monospace;
}

.border-subtle { border-color: rgba(255,255,255,0.1) !important; }
.cursor-pointer { cursor: pointer; }

/* Welcome banner */
.welcome-banner {
    background: var(--gradient-royal);
    border: none;
    color: white;
}

.welcome-banner p { color: rgba(255,255,255,0.8); }

.welcome-banner .btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    backdrop-filter: blur(10px);
}

.welcome-banner .btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Progress bars for monitoring */
.progress-royal {
    background: var(--card-bg-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 8px;
}

.progress-royal .progress-bar {
    border-radius: var(--radius-sm);
    transition: width var(--transition-normal);
}

/* Hardware info values */
.hw-value {
    font-size: 1rem;
    font-weight: 600;
}

/* Pricing card */
.pricing-card {
    border: 2px solid rgba(255,255,255,0.1);
    text-align: center;
}

.pricing-card-featured {
    border-color: var(--royal-blue);
    position: relative;
}

.pricing-card-gold {
    border-color: rgba(255,215,0,0.3);
}

.pricing-price {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-royal);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pricing-price-gold {
    background: linear-gradient(135deg, #FFD700, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pricing-feature-list {
    list-style: none;
    padding: 0;
    text-align: start;
    color: var(--text-muted);
}

.pricing-feature-list li {
    margin-bottom: 8px;
}

/* Chart bars (usage page) */
.chart-bar-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding: 0 8px;
}

.chart-bar {
    flex: 1;
    background: var(--gradient-royal);
    border-radius: 6px 6px 0 0;
    position: relative;
    cursor: pointer;
    min-width: 30px;
    transition: opacity var(--transition-fast);
}

.chart-bar:hover { opacity: 0.85; }

.chart-bar-label {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}


/* ============================================
   AUTH PAGES
   ============================================ */

.auth-container {
    max-width: 440px;
    margin: 60px auto;
}

.auth-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 40px;
    border: 1px solid rgba(65, 105, 225, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo img {
    height: 80px;
    max-width: 250px;
    object-fit: contain;
    margin-bottom: 16px;
}

.auth-logo h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 12px;
    background: var(--gradient-royal);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}


/* ============================================
   FOOTER
   ============================================ */

.portal-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}


/* ============================================
   USER AVATARS
   ============================================ */

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-royal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
    color: white;
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-royal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: white;
}

/* Legacy user badge (topbar) */
.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(65, 105, 225, 0.1);
    border-radius: var(--radius-full);
    border: 1px solid rgba(65, 105, 225, 0.3);
}


/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Large tablets / small desktops */
@media (max-width: 992px) {
    .portal-sidebar { width: var(--sidebar-collapsed-width); }
    .portal-sidebar .nav-label { opacity: 0; width: 0; overflow: hidden; }
    .portal-sidebar .sidebar-nav-item { justify-content: center; padding: 11px 0; }
    .portal-sidebar .sidebar-nav-group-header { justify-content: center; padding: 11px 0; }
    .portal-sidebar .sidebar-nav-group-items .sidebar-nav-item { padding-left: 0; }
    .portal-sidebar .sidebar-nav-divider { text-align: center; padding: 8px 4px 4px; font-size: 0.6rem; }
    .portal-sidebar .sidebar-logo { justify-content: center; padding: 20px 12px 16px; }
    .portal-sidebar .sidebar-logo img { height: 32px; max-width: 40px; }
    .portal-sidebar .sidebar-user { justify-content: center; padding: 16px 12px; }
    .portal-sidebar .sidebar-toggle-btn { display: none; }

    .portal-main { margin-left: var(--sidebar-collapsed-width); }
    .portal-topbar { left: var(--sidebar-collapsed-width); }
    .portal-content { padding: 88px 20px 20px; }
}

/* Tablets / phones */
@media (max-width: 768px) {
    .portal-sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        box-shadow: none;
    }

    .portal-sidebar .nav-label { opacity: 1; width: auto; }
    .portal-sidebar .sidebar-nav-item { justify-content: flex-start; padding: 11px 16px; }
    .portal-sidebar .sidebar-nav-group-header { justify-content: flex-start; padding: 11px 16px; }
    .portal-sidebar .sidebar-nav-group-items .sidebar-nav-item { padding-left: 28px; }
    .portal-sidebar .sidebar-nav-divider { text-align: left; padding: 12px 28px 4px; }
    .portal-sidebar .sidebar-logo { justify-content: flex-start; padding: 20px 20px 16px; }
    .portal-sidebar .sidebar-logo img { height: 36px; max-width: 140px; }
    .portal-sidebar .sidebar-user { justify-content: flex-start; padding: 16px 20px; }
    .portal-sidebar .sidebar-toggle-btn { display: none; }

    .portal-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.5);
    }

    .portal-main { margin-left: 0; }
    .portal-topbar { left: 0; }
    .portal-content { padding: 80px 16px 16px; }

    .hamburger-btn { display: flex; }

    .portal-card { padding: 20px; }
    .stat-value { font-size: 1.5rem; }
    .voucher-code { font-size: 1.1rem; padding: 12px 16px; }

    .auth-card { padding: 28px; margin: 20px; }
}

/* Small phones */
@media (max-width: 576px) {
    .portal-content { padding: 76px 12px 12px; }
    .portal-card { padding: 16px; border-radius: var(--radius-lg); }
    .stat-card { padding: 16px; border-radius: var(--radius-lg); }
    .portal-topbar { padding: 0 16px; }
    .toast-royal { min-width: 260px; max-width: calc(100vw - 40px); }
}

/* Prevent body scroll when mobile sidebar open */
body.sidebar-mobile-open { overflow: hidden; }

/* Dropdown (Bootstrap override for dark theme) */
.dropdown-menu-dark {
    background: var(--card-bg);
    border: 1px solid rgba(65, 105, 225, 0.3);
    border-radius: var(--radius-md);
    padding: 8px;
}

.dropdown-menu-dark .dropdown-item {
    border-radius: var(--radius-sm);
    color: var(--text-light);
    padding: 8px 16px;
    transition: background var(--transition-fast);
}

.dropdown-menu-dark .dropdown-item:hover {
    background: rgba(65, 105, 225, 0.15);
}

.dropdown-menu-dark .dropdown-header {
    color: var(--royal-blue);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.dropdown-menu-dark .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Form Switch Override */
.form-check-input:checked {
    background-color: var(--royal-blue);
    border-color: var(--royal-blue);
}

/* ============================================
   Utility Classes
   ============================================ */

/* --- Text & Color Utilities --- */
.text-muted-portal {
    color: var(--text-muted) !important;
}

.icon-blue {
    color: var(--royal-blue) !important;
}

.icon-success {
    color: var(--success) !important;
}

.icon-warning {
    color: var(--warning) !important;
}

.icon-gold {
    color: var(--accent-gold) !important;
}

/* --- Font Size Utilities (icons) --- */
.fs-icon-xl {
    font-size: 3rem !important;
}

.fs-icon-2xl {
    font-size: 4rem !important;
}

/* --- Code Badge --- */
.code-badge {
    background: rgba(65, 105, 225, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--royal-blue-light);
}

/* --- Border Subtle --- */
.border-subtle {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

hr.border-subtle {
    border-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--text-muted);
    display: inline-block;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-light);
    margin-top: 0.75rem;
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* --- Modal Royal (Dark Theme) --- */
.modal-royal {
    background: rgba(0, 0, 0, 0.7);
}

.modal-royal .modal-content {
    background: var(--card-bg);
    border: 1px solid rgba(65, 105, 225, 0.3);
    border-radius: 16px;
    color: var(--text-light);
}

.modal-royal .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-royal .modal-title {
    color: var(--text-light);
}

.modal-royal .modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- Pricing Cards --- */
.pricing-card {
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.pricing-card-featured {
    border-color: var(--royal-blue);
}

.pricing-card-gold {
    border-color: rgba(255, 215, 0, 0.3);
}

.pricing-card-price {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-royal);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
