/* ====================================
   MTA Shield — Admin Panel Styles
   ==================================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #0f0f16;
    --bg-card: #14141e;
    --bg-sidebar: #0c0c14;
    --bg-input: #1a1a28;
    --bg-hover: #1e1e2e;
    --bg-active: rgba(0, 180, 255, 0.08);

    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-focus: rgba(0, 180, 255, 0.4);

    --text-primary: #eeeef2;
    --text-secondary: #8888a0;
    --text-muted: #55556a;

    --blue: #00b4ff;
    --purple: #6366f1;
    --green: #00ff88;
    --green-soft: #10b981;
    --red: #ff4466;
    --yellow: #fbbf24;
    --cyan: #06b6d4;

    --gradient: linear-gradient(135deg, #00b4ff, #6366f1);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Consolas', monospace;

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;

    --transition: 0.2s ease;
    --sidebar-width: 240px;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ====== Screens ====== */
.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: flex;
}

/* ====================================
   LOGIN / SETUP SCREEN
   ==================================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

.login-glow {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(0, 180, 255, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.accent {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9375rem;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 180, 255, 0.08);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-error {
    color: var(--red);
    font-size: 0.8125rem;
    margin-bottom: 12px;
    min-height: 20px;
}

.form-group.inline {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.form-group.inline input {
    flex: 1;
}

/* ====== Buttons ====== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 180, 255, 0.3);
}

.btn-full {
    width: 100%;
    padding: 13px;
    font-size: 0.9375rem;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-sm { padding: 5px 10px; font-size: 0.75rem; }

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: rgba(255, 68, 102, 0.1);
    color: var(--red);
    border: 1px solid rgba(255, 68, 102, 0.2);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger:hover {
    background: rgba(255, 68, 102, 0.2);
}

.btn-detail {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: rgba(0, 180, 255, 0.1);
    color: var(--blue);
    border: 1px solid rgba(0, 180, 255, 0.2);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-detail:hover {
    background: rgba(0, 180, 255, 0.2);
}

.link-btn {
    background: none;
    border: none;
    color: var(--blue);
    font-family: var(--font);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.link-btn:hover {
    color: var(--text-primary);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ====================================
   DASHBOARD LAYOUT
   ==================================== */
#dashboard-screen {
    display: none;
}
#dashboard-screen.active {
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 800;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-item.active {
    color: var(--blue);
    background: var(--bg-active);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.admin-info span {
    font-size: 0.8125rem;
    font-weight: 600;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
}

.logout-btn:hover {
    color: var(--red);
    background: rgba(255, 68, 102, 0.1);
}

/* ====== Main Content ====== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 28px 32px;
    min-height: 100vh;
}

.page {
    display: none;
}
.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ====== Stats Grid ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: rgba(0, 180, 255, 0.1); color: var(--blue); }
.stat-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--green-soft); }
.stat-icon.purple { background: rgba(99, 102, 241, 0.1); color: var(--purple); }
.stat-icon.red { background: rgba(255, 68, 102, 0.1); color: var(--red); }

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

.stat-num {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.stat-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ====== Cards ====== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 0.9375rem;
    font-weight: 700;
}

.card-body {
    padding: 16px 20px;
}

.card-body.no-pad {
    padding: 0;
}

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ====== Action Buttons ====== */
.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 8px;
}

.action-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: var(--bg-active);
}

.action-btn:last-child {
    margin-bottom: 0;
}

/* ====== PIN Manager ====== */
.pin-actions {
    margin-bottom: 20px;
}

.generate-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

/* ====== PIN Display (Modal) ====== */
.pin-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--blue);
    border-radius: var(--radius);
    padding: 20px;
    margin: 20px 0 12px;
}

.pin-code {
    font-family: var(--mono);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.copy-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.copy-btn:hover {
    color: var(--blue);
    border-color: var(--blue);
}

.pin-label-display {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ====== Tables ====== */
.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.data-table th {
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.6875rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.empty-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px !important;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--green-soft);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-used {
    background: rgba(0, 180, 255, 0.1);
    color: var(--blue);
    border: 1px solid rgba(0, 180, 255, 0.2);
}

.status-expired {
    background: rgba(255, 187, 36, 0.1);
    color: var(--yellow);
    border: 1px solid rgba(255, 187, 36, 0.2);
}

.status-revoked {
    background: rgba(255, 68, 102, 0.1);
    color: var(--red);
    border: 1px solid rgba(255, 68, 102, 0.2);
}

.status-clean {
    background: rgba(0, 255, 136, 0.1);
    color: var(--green);
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.status-threat {
    background: rgba(255, 68, 102, 0.1);
    color: var(--red);
    border: 1px solid rgba(255, 68, 102, 0.2);
}

.pin-mono {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.03em;
}

/* ====== Modal ====== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    width: 90%;
    max-width: 460px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: modalIn 0.25s ease;
}

.modal-lg {
    max-width: 720px;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    transition: var(--transition);
}

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

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

.modal-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Scan detail inside modal */
.scan-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-item {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.detail-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 4px;
}

.detail-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 600;
}

.detail-value.mono {
    font-family: var(--mono);
    font-size: 0.8125rem;
}

.threats-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
}

.threat-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.threat-item:last-child {
    border-bottom: none;
}

.threat-item .threat-badge {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.threat-badge.detected {
    background: rgba(255, 68, 102, 0.15);
    color: var(--red);
}

.threat-badge.suspicious {
    background: rgba(255, 187, 36, 0.15);
    color: var(--yellow);
}

.threat-info {
    flex: 1;
    min-width: 0;
}

.threat-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.threat-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    word-break: break-all;
}

/* Recent scans on dashboard */
.recent-scan-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.recent-scan-item:last-child {
    border-bottom: none;
}

.recent-scan-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.recent-scan-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.recent-scan-dot.clean { background: var(--green-soft); }
.recent-scan-dot.threat { background: var(--red); }

.recent-scan-pin {
    font-family: var(--mono);
    font-size: 0.8125rem;
    font-weight: 600;
}

.recent-scan-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.recent-scan-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ====== Toast ====== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-primary);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 2000;
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success { border-color: var(--green-soft); }
.toast.error { border-color: var(--red); }

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

/* ====== Responsive ====== */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr; }
    .scan-detail-grid { grid-template-columns: 1fr; }
}
