/* ============================================================
   KEY MANAGEMENT PANEL - MAIN STYLESHEET
   Responsive design for mobile + PC | Dark/Light theme support
   ============================================================ */

/* CSS Variables for Theming */
:root {
    /* Dark Futuristic Theme */
    --bg-primary: #0a0f0f;
    --bg-secondary: #0d1717;
    --bg-card: #132626;
    --bg-input: #0f1e1e;
    --bg-hover: #1a3535;
    
    --text-primary: #ffffff;
    --text-secondary: #94b8b8;
    --text-muted: #6a8a8a;
    
    /* Green/Teal/Cyan Theme */
    --accent-primary: #10b981;
    --accent-secondary: #06b6d4;
    --accent-tertiary: #14b8a6;
    --accent-gradient: linear-gradient(135deg, #10b981 0%, #06b6d4 50%, #22d3ee 100%);
    --accent-gradient-reverse: linear-gradient(135deg, #06b6d4 0%, #10b981 100%);
    --glow-color: rgba(16, 185, 129, 0.4);
    --glow-purple: 0 0 20px rgba(16, 185, 129, 0.5);
    --glow-pink: 0 0 20px rgba(6, 182, 212, 0.5);
    --glow-sm: 0 0 10px rgba(16, 185, 129, 0.3);
    --glow-md: 0 0 20px rgba(16, 185, 129, 0.4);
    --glow-lg: 0 0 40px rgba(16, 185, 129, 0.5), 0 0 80px rgba(6, 182, 212, 0.2);
    --glow-intense: 0 0 30px rgba(16, 185, 129, 0.6), 0 0 60px rgba(6, 182, 212, 0.3);
    
    /* Grid for background */
    --grid-color: rgba(16, 185, 129, 0.03);
    
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --border-color: rgba(16, 185, 129, 0.2);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    
    --sidebar-width: 230px;
    --header-height: 56px;
    --border-radius: 6px;
    --border-radius-sm: 4px;
    --transition: all 0.25s ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f0fdf4;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ecfdf5;
    --bg-hover: #d1fae5;
    
    --text-primary: #134e4a;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    
    --accent-primary: #059669;
    --accent-secondary: #0891b2;
    
    --border-color: rgba(5, 150, 105, 0.2);
    --shadow: 0 4px 20px rgba(5, 150, 105, 0.1);
    --shadow-lg: 0 10px 40px rgba(5, 150, 105, 0.15);
    --grid-color: rgba(5, 150, 105, 0.03);
    --glow-color: rgba(5, 150, 105, 0.2);
    --glow-purple: 0 0 15px rgba(5, 150, 105, 0.3);
    --glow-pink: 0 0 15px rgba(8, 145, 178, 0.3);
    --glow-sm: 0 0 8px rgba(5, 150, 105, 0.2);
    --glow-md: 0 0 15px rgba(5, 150, 105, 0.25);
    --glow-lg: 0 0 30px rgba(5, 150, 105, 0.3);
    --glow-intense: 0 0 20px rgba(5, 150, 105, 0.35);
}

/* Light Mode specific overrides */
[data-theme="light"] body {
    background: 
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px) 0 0 / 50px 50px,
        linear-gradient(var(--grid-color) 1px, transparent 1px) 0 0 / 50px 50px,
        radial-gradient(ellipse at 20% 20%, rgba(5, 150, 105, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(8, 145, 178, 0.06) 0%, transparent 50%),
        var(--bg-primary);
}

[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

[data-theme="light"] .header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 253, 244, 0.95) 100%);
}

[data-theme="light"] .sidebar-logo {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(135deg, #059669, #0891b2);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] .card {
    background: #ffffff;
    box-shadow: 0 2px 15px rgba(147, 51, 234, 0.08);
}

[data-theme="light"] .stat-card {
    background: #ffffff;
}

[data-theme="light"] .nav-link:hover {
    background: linear-gradient(90deg, rgba(5, 150, 105, 0.1) 0%, transparent 100%);
}

[data-theme="light"] .nav-link.active {
    background: linear-gradient(90deg, rgba(5, 150, 105, 0.15) 0%, transparent 100%);
    color: #134e4a;
}

[data-theme="light"] .table th {
    background: #f5f3ff;
    color: #4b5563;
}

[data-theme="light"] .table tbody tr:hover {
    background: #faf5ff;
}

[data-theme="light"] .btn-primary {
    background: linear-gradient(135deg, #059669 0%, #0891b2 100%);
    color: #ffffff;
}

[data-theme="light"] .form-control {
    background: #f9fafb;
    border-color: rgba(5, 150, 105, 0.2);
    color: #134e4a;
}

[data-theme="light"] .form-control:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    font-size: 16px;
    overflow-x: hidden;
    max-width: 100vw;
}

body.sidebar-open {
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: 
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px) 0 0 / 50px 50px,
        linear-gradient(var(--grid-color) 1px, transparent 1px) 0 0 / 50px 50px,
        radial-gradient(ellipse at 20% 20%, rgba(16, 185, 129, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
        var(--bg-primary);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-secondary);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app-container {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Sidebar Overlay - Base styles (always present) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 2px solid var(--accent-primary);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar::after {
    display: none;
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--bg-hover);
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.sidebar-close:hover {
    background: var(--danger);
    color: #fff;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(16, 185, 129, 0.05);
}

.sidebar-logo {
    font-size: 1.35rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

@keyframes neon-flicker {
    0%, 100% { filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.8)); }
    50% { filter: drop-shadow(0 0 20px rgba(6, 182, 212, 0.8)); }
}

.sidebar-nav {
    padding: 15px 0;
}

.nav-section {
    padding: 0 15px;
    margin-bottom: 20px;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 15px;
    letter-spacing: 0.5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 15px;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    transition: all 0.25s ease;
    margin-bottom: 2px;
    position: relative;
    overflow: hidden;
    border-left: 3px solid transparent;
}

.nav-link::before {
    display: none;
}

.nav-link:hover {
    background: rgba(16, 185, 129, 0.1);
    color: var(--text-primary);
    border-left-color: var(--accent-secondary);
    transform: none;
}

.nav-link:hover::before {
    display: none;
}

.nav-link.active {
    background: rgba(16, 185, 129, 0.15);
    color: #fff;
    border-left: 3px solid var(--accent-primary);
    box-shadow: none;
}

.nav-link.active::before {
    display: none;
}

.nav-link svg, .nav-link .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - var(--sidebar-width));
    overflow-x: hidden;
}

/* Header - Clean Modern Design */
.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
}

.header::before {
    display: none;
}

@keyframes scanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

.header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gradient);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    z-index: 10;
}

.menu-toggle {
    display: none;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--border-radius-sm);
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 100;
}

.menu-toggle:hover,
.menu-toggle:active {
    background: var(--accent-gradient);
    border-color: var(--accent-primary);
    color: #fff;
    box-shadow: var(--glow-sm);
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 10;
}

.theme-toggle {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 100;
}

.theme-toggle::before {
    display: none;
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    color: #fff;
    transform: none;
}

.theme-toggle:hover::before {
    display: none;
}

.theme-toggle i {
    position: relative;
    z-index: 1;
    transition: color 0.3s ease;
}

.theme-toggle:hover i {
    color: #fff;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.user-menu:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    position: relative;
}

.user-avatar::before {
    display: none;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Page Content */
.page-content {
    padding: 20px;
    flex: 1;
    max-width: 100%;
    overflow-x: hidden;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-primary);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    z-index: 1;
}

.card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
    border-left-color: var(--accent-secondary);
}

.card::before {
    display: none;
}

.card:hover::before {
    display: none;
}

@keyframes gradient-border-rotate {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-gradient);
}

.stat-card::after {
    display: none;
}

.stat-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.stat-card:hover::after {
    display: none;
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.primary { background: rgba(16, 185, 129, 0.15); color: var(--accent-primary); }
.stat-icon.success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon.info { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.stat-icon.secondary { background: rgba(6, 182, 212, 0.15); color: var(--accent-secondary); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-primary::before {
    display: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:hover::before {
    display: none;
}

@keyframes button-glow {
    0%, 100% { opacity: 0.4; filter: blur(10px); }
    50% { opacity: 0.7; filter: blur(15px); }
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238b949e'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-error {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 6px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    max-width: 100%;
}

/* Force grid layouts to respect container */
.grid,
[style*="display: grid"],
[style*="display:grid"] {
    max-width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--bg-input);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-primary { background: rgba(124, 58, 237, 0.15); color: var(--accent-primary); }

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success { background: rgba(34, 197, 94, 0.15); border-left: 3px solid var(--success); }
.alert-warning { background: rgba(245, 158, 11, 0.15); border-left: 3px solid var(--warning); }
.alert-danger { background: rgba(239, 68, 68, 0.15); border-left: 3px solid var(--danger); }
.alert-info { background: rgba(59, 130, 246, 0.15); border-left: 3px solid var(--info); }

.alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 4px;
}

/* View More Button */
.btn-view-more {
    background: transparent;
    border: 1px dashed var(--accent-primary);
    color: var(--accent-primary);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-view-more:hover {
    background: var(--accent-primary);
    color: #fff;
}

.alert-extra-item {
    margin-top: 4px;
}

/* Extra table rows (hidden by default) */
tr.extra-row {
    display: none;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 25px;
}

.pagination ul {
    display: flex;
    list-style: none;
    gap: 5px;
}

.pagination li a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.pagination li a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination li.active a {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

/* Key Display */
.key-display {
    background: var(--bg-input);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    margin: 20px 0;
}

.key-value {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    word-break: break-all;
    margin-bottom: 15px;
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.copy-btn:hover {
    opacity: 0.9;
}

.copy-btn.copied {
    background: var(--success);
}

/* Balance Display */
.balance-display {
    background: var(--accent-gradient);
    border-radius: var(--border-radius);
    padding: 25px;
    color: #fff;
    text-align: center;
}

.balance-label {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.balance-value {
    font-size: 2.5rem;
    font-weight: 700;
}

.balance-alert {
    font-size: 0.8125rem;
    opacity: 0.8;
    margin-top: 10px;
}

/* Product Cards */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    transition: var(--transition);
    cursor: pointer;
}

.product-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.product-card.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.product-duration {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 15px;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.product-stock {
    font-size: 0.8125rem;
    margin-top: 10px;
}

.product-stock.low {
    color: var(--warning);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-primary);
}

.login-box {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.login-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.login-tab {
    flex: 1;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.login-tab:hover {
    background: var(--bg-hover);
}

.login-tab.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100vw;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .sidebar-close {
        display: flex;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header {
        padding: 0 15px;
    }
    
    .page-content {
        padding: 15px;
        overflow-x: hidden;
    }
    
    .card {
        padding: 15px;
    }
    
    .user-info {
        display: none;
    }
    
    /* Hide elements on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    .table th,
    .table td {
        padding: 10px;
        font-size: 0.875rem;
    }
    
    /* Fix inline grid layouts */
    [style*="grid-template-columns"][style*="350px"],
    [style*="grid-template-columns: 1fr 350px"] {
        display: block !important;
    }
    
    [style*="grid-template-columns"] > * {
        width: 100% !important;
        margin-bottom: 15px;
    }
    
    /* Fix inline min-width flex items */
    [style*="min-width: 1"],
    [style*="min-width: 2"] {
        min-width: 0 !important;
        flex: 1 1 100% !important;
    }
    
    /* Filter forms responsive */
    .d-flex[style*="flex-wrap"],
    form[style*="flex"] {
        flex-wrap: wrap !important;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .login-box {
        padding: 25px;
    }
    
    .balance-value {
        font-size: 2rem;
    }
    
    .modal {
        width: 95%;
    }
}

/* ============================================================
   RESPONSIVE GRID HELPERS
   ============================================================ */

.responsive-grid {
    display: grid;
    grid-template-columns: 1fr minmax(280px, 350px);
    gap: 1.5rem;
}

.responsive-grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 1.5rem;
}

.responsive-grid-wide {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .responsive-grid,
    .responsive-grid-wide {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.w-100 { width: 100%; }
.hidden { display: none !important; }

/* Scrollbar - Cyberpunk Style */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-left: 1px solid rgba(168, 85, 247, 0.1);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-secondary), var(--accent-primary));
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.5);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Clickable Key Code */
code.key-code {
    cursor: pointer;
    position: relative;
}

code.key-code:hover {
    background: var(--accent-primary) !important;
    color: #fff;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

code.key-code::after {
    content: 'Click to copy';
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

code.key-code:hover::after {
    opacity: 1;
}

/* ============================================================
   KEY BLUR (Screen Share Protection)
   ============================================================ */
.key-blur {
    filter: blur(5px);
    transition: filter 0.2s ease;
    user-select: none;
}

.key-blur.revealed {
    filter: blur(0);
    user-select: auto;
}

/* Tooltip hint for blurred keys */
.key-blur-wrapper {
    position: relative;
    display: inline-block;
}

.key-blur-wrapper::before {
    content: '🔒 Click to reveal';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.7;
    pointer-events: none;
    z-index: 1;
    white-space: nowrap;
}

.key-blur-wrapper.revealed::before {
    display: none;
}
