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

/* --- DESIGN SYSTEM & CSS VARIABLES --- */
:root {
    /* Fonts */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Theme Colors - Light Mode (Default) */
    --bg-app: hsl(220, 30%, 96%);
    --bg-sidebar: rgba(255, 255, 255, 0.7);
    --bg-card: rgba(255, 255, 255, 0.65);
    --bg-input: rgba(255, 255, 255, 0.9);
    --border-color: rgba(226, 232, 240, 0.8);
    --text-primary: hsl(220, 40%, 15%);
    --text-secondary: hsl(220, 20%, 45%);
    --text-muted: hsl(220, 15%, 65%);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.06);
    --glass-border: rgba(255, 255, 255, 0.4);

    /* Accent Colors */
    --primary: hsl(250, 84%, 63%);
    --primary-gradient: linear-gradient(135deg, hsl(250, 84%, 63%) 0%, hsl(280, 84%, 60%) 100%);
    --primary-light: hsl(250, 84%, 95%);
    
    --success: hsl(142, 72%, 40%);
    --success-light: hsl(142, 72%, 95%);
    --success-gradient: linear-gradient(135deg, hsl(142, 72%, 40%) 0%, hsl(160, 80%, 40%) 100%);
    
    --warning: hsl(38, 92%, 50%);
    --warning-light: hsl(38, 92%, 95%);
    
    --danger: hsl(350, 80%, 55%);
    --danger-light: hsl(350, 80%, 96%);
    --danger-gradient: linear-gradient(135deg, hsl(350, 80%, 55%) 0%, hsl(340, 90%, 50%) 100%);

    --info: hsl(199, 89%, 48%);
    --info-light: hsl(199, 89%, 95%);

    --sidebar-width: 260px;
    --transition-speed: 0.3s;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

/* Dark Mode Variables override */
[data-theme="dark"] {
    --bg-app: hsl(224, 71%, 4%);
    --bg-sidebar: rgba(10, 15, 30, 0.65);
    --bg-card: rgba(15, 23, 42, 0.55);
    --bg-input: rgba(30, 41, 59, 0.5);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 75%);
    --text-muted: hsl(215, 15%, 50%);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-border: rgba(255, 255, 255, 0.05);

    --primary-light: hsl(250, 40%, 15%);
    --success-light: hsl(142, 40%, 12%);
    --warning-light: hsl(38, 40%, 12%);
    --danger-light: hsl(350, 40%, 14%);
    --info-light: hsl(199, 40%, 12%);
}

/* --- RESET & GENERAL --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
}

/* --- GLASS CONTAINER STYLING --- */
.glass-effect {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background-color: var(--bg-card);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* --- MAIN LAYOUT --- */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    border-right: 1px solid var(--border-color);
    transition: all var(--transition-speed);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    padding-left: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.logo-icon.has-brand-logo {
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.brand-logo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-item a svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: transform 0.2s;
}

.nav-item a:hover {
    color: var(--primary);
    background-color: var(--primary-light);
    border-color: var(--border-color);
}

.nav-item a:hover svg {
    transform: translateX(3px);
}

.nav-item.active a {
    color: #fff;
    background: var(--primary-gradient);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.25);
}

.nav-item.active a svg {
    color: #fff;
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-profile-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.admin-avatar {
    display: grid;
    place-items: center;
    background: var(--primary-gradient);
    color: #fff;
    font-size: .8rem;
    font-weight: 800;
}

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

.user-name-summary {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role-summary {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- MAIN CONTENT & HEADER --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 2rem 2.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
    width: calc(100% - var(--sidebar-width));
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.page-title h1 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.page-title p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Search Bar */
.search-bar {
    position: relative;
    width: 260px;
}

.search-bar input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-bar svg {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

/* Theme Toggle Button */
.theme-toggle-btn, .notification-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle-btn:hover, .notification-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
    border-color: var(--primary);
}

.theme-toggle-btn svg, .notification-btn svg {
    width: 20px;
    height: 20px;
}

.notification-btn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-app);
}

/* --- CARDS & GRIDS --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.card {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.06);
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.card-icon {
    width: 45px;
    height: 45px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon svg {
    width: 22px;
    height: 22px;
}

.card-info {
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.card-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.card-trend {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.trend-up {
    color: var(--success);
}
.trend-down {
    color: var(--danger);
}

/* Graph / Visual cards */
.visual-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .visual-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-container {
    flex-grow: 1;
    position: relative;
    width: 100%;
    height: 100%;
    margin-top: 1.5rem;
    display: flex;
    align-items: flex-end;
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- TABLES --- */
.table-container {
    overflow-x: auto;
    width: 100%;
    border-radius: var(--radius-md);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    background-color: rgba(0, 0, 0, 0.02);
    padding: 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

[data-theme="dark"] .custom-table th {
    background-color: rgba(255, 255, 255, 0.02);
}

.custom-table td {
    padding: 1.1rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.custom-table tr {
    transition: background-color 0.15s;
}

.custom-table tr:hover {
    background-color: rgba(99, 102, 241, 0.02);
}

/* Badges for status */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-active {
    background-color: var(--success-light);
    color: var(--success);
}
.badge-active::before {
    background-color: var(--success);
}

.badge-warning {
    background-color: var(--warning-light);
    color: var(--warning);
}
.badge-warning::before {
    background-color: var(--warning);
}

.badge-expired, .badge-danger {
    background-color: var(--danger-light);
    color: var(--danger);
}
.badge-expired::before, .badge-danger::before {
    background-color: var(--danger);
}

.badge-info {
    background-color: var(--info-light);
    color: var(--info);
}
.badge-info::before {
    background-color: var(--info);
}

/* Code element formatting for keys */
.key-code {
    font-family: monospace;
    font-size: 0.85rem;
    background-color: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(99, 102, 241, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.copy-btn-inline {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.copy-btn-inline:hover {
    color: var(--primary);
}

.copy-btn-inline svg {
    width: 14px;
    height: 14px;
}

/* --- FORMS & INPUTS --- */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-card {
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    padding: 2rem;
    transform: scale(0.9);
    transition: transform var(--transition-speed);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.modal-close-btn svg {
    width: 18px;
    height: 18px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* --- TIMELINE (For History Page) --- */
.timeline {
    position: relative;
    padding-left: 2rem;
    margin-top: 1rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -2rem;
    top: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid var(--bg-app);
    background-color: var(--text-muted);
}

.timeline-dot.success { background-color: var(--success); }
.timeline-dot.warning { background-color: var(--warning); }
.timeline-dot.danger { background-color: var(--danger); }
.timeline-dot.info { background-color: var(--info); }

.timeline-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--glass-shadow);
}

.timeline-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.timeline-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.timeline-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    color: var(--text-primary);
    animation: toast-slide-in 0.3s ease forwards;
    min-width: 280px;
    border-left: 4px solid var(--text-muted);
}

.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }

.toast-icon svg {
    width: 20px;
    height: 20px;
}
.toast.success .toast-icon { color: var(--success); }
.toast.danger .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--info); }

.toast-message {
    font-size: 0.875rem;
    font-weight: 500;
}

@keyframes toast-slide-in {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- ANIMATED BG FOR LOGIN --- */
.login-bg {
    position: fixed;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background-color: hsl(224, 71%, 4%);
}

.login-blob {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: float 20s infinite alternate;
}

.login-blob-1 {
    background-color: var(--primary);
    left: -100px;
    top: -100px;
}

.login-blob-2 {
    background-color: hsl(280, 84%, 60%);
    right: -100px;
    bottom: -100px;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(80px, 50px) scale(1.1); }
}

/* --- SCANNED PAGE GRAPHICS --- */
.scan-visualizer {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    height: 180px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-radar {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.2);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-radar::before {
    content: '';
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.4);
}

.scan-radar::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.6);
}

.scan-line {
    position: absolute;
    width: 50%;
    height: 2px;
    background: linear-gradient(to right, rgba(99, 102, 241, 0), var(--primary));
    transform-origin: left center;
    left: 50%;
    top: 50%;
    animation: rotate-radar 3s linear infinite;
}

@keyframes rotate-radar {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.scan-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
    opacity: 0;
    animation: pulse-dot 2s infinite;
}

.scan-dot-1 { top: 30%; left: 40%; animation-delay: 0.5s; }
.scan-dot-2 { top: 70%; left: 65%; animation-delay: 1.5s; }
.scan-dot-3 { top: 45%; left: 80%; animation-delay: 2.2s; }

@keyframes pulse-dot {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0; transform: scale(0.5); }
}

/* --- MOBILE RESPONSIVENESS & BURGER MENU --- */
.burger-menu {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 0 0 30px rgba(0,0,0,0.15);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem;
    }
    
    .burger-menu {
        display: flex;
    }
}
