/* ================================================================
   AccessSentryHUB · Admin · emerald-on-dark
   Дизайн-токени — див. /Users/rrv/Documents/DEV_API/AccessSentry/DESIGN-REFERENCE.md
   ================================================================ */

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

:root {
    --bg-primary:   #0F1117;
    --bg-secondary: #1A1D24;
    --bg-tertiary:  #22262F;
    --bg-hover:     #2A2F3A;
    --text-primary: #F0F2F5;
    --text-secondary: #9CA3AF;
    --text-muted:   #6B7280;
    --accent:       #10B981;
    --accent-hover: #059669;
    --accent-pressed:#047857;
    --cyan:         #06B6D4;
    --border:       #2D3139;
    --warning:      #F59E0B;
    --danger:       #EF4444;
    --radius:       12px;
    --radius-sm:    8px;
    --radius-lg:    16px;
    --sidebar-w:    260px;
    --t-fast:       150ms ease;
    --t-norm:       250ms ease;
}

html { font-size: 14px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ===== APP LAYOUT ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; height: 100vh; z-index: 100;
}
.sidebar-header { padding: 20px 18px; border-bottom: 1px solid var(--border); }
.logo {
    display: flex; align-items: center; gap: 12px;
    font-size: 1.15rem; font-weight: 700; font-style: italic;
    color: var(--text-primary);
}
.logo .mark {
    width: 36px; height: 36px;
    border-radius: 9px;
    background: rgba(16,185,129,0.15);
    border: 1px solid rgba(16,185,129,0.3);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
}
.logo .mark svg { width: 20px; height: 20px; }
.logo .accent { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-section {
    font-size: 10px; letter-spacing: 1.5px;
    color: var(--text-muted); font-weight: 700;
    margin: 12px 4px 6px; text-transform: uppercase;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--t-fast);
    font-size: 13px; font-weight: 500;
    cursor: pointer; user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; }
.nav-item.active:hover { background: var(--accent-hover); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 11px; }
.sidebar-footer .row { display: flex; justify-content: space-between; align-items: center; color: var(--text-muted); margin-bottom: 4px; }
.sidebar-footer .ok { color: var(--accent); }
.sidebar-footer .logout-btn {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 12px; margin-top: 8px;
    background: transparent; border: none; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 12px;
    transition: var(--t-fast);
}
.sidebar-footer .logout-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer .logout-btn:hover { background: rgba(239,68,68,0.1); color: var(--danger); }

.main { flex: 1; margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.top-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.top-header h1 { font-size: 1.4rem; font-weight: 600; }
.top-header .right { display: flex; align-items: center; gap: 18px; color: var(--text-secondary); font-size: 13px; }

.content { flex: 1; padding: 28px 32px; overflow-y: auto; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 18px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-content { padding: 22px; }

/* ===== STATS ===== */
.stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex; gap: 14px;
    transition: all var(--t-norm);
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--cyan));
    opacity: 0; transition: opacity var(--t-norm);
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.5);
    border-color: var(--accent);
}
.stat-card:hover::before { opacity: 1; }
.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all var(--t-norm);
    background: rgba(16,185,129,0.15); color: var(--accent);
}
.stat-card .stat-icon svg { width: 22px; height: 22px; }
.stat-card:hover .stat-icon { transform: scale(1.08) rotate(5deg); }
.stat-card .stat-icon.cyan { background: rgba(6,182,212,0.15); color: var(--cyan); }
.stat-card .stat-icon.warn { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-card .stat-icon.danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.stat-card .stat-label { font-size: 10.5px; letter-spacing: 1.5px; color: var(--text-muted); font-weight: 700; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 3px; color: var(--text-primary); }
.stat-card .stat-hint { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px;
    border: none; border-radius: var(--radius-sm);
    font-weight: 500; font-size: 13px;
    transition: var(--t-fast);
    cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-pressed); }
.btn-block { width: 100%; }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid #7F1D1D; }
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ===== INPUTS ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; margin-bottom: 8px;
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.form-input {
    width: 100%; padding: 11px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--t-fast);
    font-size: 13px;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.form-input::placeholder { color: var(--text-muted); }
.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-left: 44px; }
.input-wrapper .icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--text-muted);
    pointer-events: none;
}

/* ===== STATUS / BADGE ===== */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.warn { background: var(--warning); box-shadow: 0 0 8px var(--warning); animation: pulse 2s infinite; }
.dot.err { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.dot.muted { background: var(--text-muted); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.55} }

.badge {
    display: inline-block;
    padding: 3px 8px; border-radius: 4px;
    font-size: 10.5px; font-weight: 700; letter-spacing: 1px;
}
.badge.ok { background: rgba(16,185,129,0.15); color: var(--accent); }
.badge.warn { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge.danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge.muted { background: var(--bg-tertiary); color: var(--text-muted); }
.badge.cyan { background: rgba(6,182,212,0.15); color: var(--cyan); }

/* ===== TABLES ===== */
.table { width: 100%; border-collapse: collapse; }
.table thead th {
    text-align: left; padding: 10px 14px;
    font-size: 10.5px; letter-spacing: 1.5px; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}
.table tbody td {
    padding: 11px 14px;
    font-size: 13px; color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}
.table tbody tr { transition: var(--t-fast); }
.table tbody tr:hover { background: var(--bg-tertiary); }
.table .mono { font-family: 'Consolas', 'Menlo', monospace; font-size: 12px; color: var(--text-secondary); }

/* ===== EMPTY STATE ===== */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 14px; }
.empty .h { color: var(--text-secondary); font-size: 16px; font-weight: 600; margin-bottom: 6px; }

/* ===== ALERT ===== */
.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 13px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert.error { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.alert.success { background: rgba(16,185,129,0.1); color: var(--accent); border: 1px solid rgba(16,185,129,0.3); }

/* ===== SECTION TITLES ===== */
.section-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 4px; }
.section-hint { font-size: 12.5px; color: var(--text-muted); margin-bottom: 18px; }

/* ===== LOGIN PAGE (повна копія LoginWindow.axaml у HTML/CSS) ===== */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.login-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.login-bg .blob { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.35; }
.login-bg .b1 { width: 560px; height: 560px; background: var(--accent); top: -150px; right: -100px; }
.login-bg .b2 { width: 480px; height: 480px; background: var(--cyan); bottom: -120px; left: -120px; opacity: 0.30; }
.login-bg .b3 { width: 380px; height: 380px; background: var(--accent); top: 45%; left: 45%; opacity: 0.18; transform: translate(-50%,-50%); }

.login-card {
    position: relative; z-index: 1;
    width: 440px; max-width: 92vw;
    background: rgba(26,29,36,0.62);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    padding: 36px 40px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.55);
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-logo {
    width: 68px; height: 68px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: rgba(16,185,129,0.14);
    border: 1px solid rgba(16,185,129,0.3);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
}
.login-logo svg { width: 36px; height: 36px; }
.login-header h1 { font-size: 24px; font-weight: 700; font-style: italic; }
.login-header .accent { color: var(--accent); }
.login-header p { color: var(--text-secondary); font-size: 12.5px; margin-top: 4px; }

.login-footer { text-align: center; margin-top: 24px; font-size: 11px; color: var(--text-muted); }
.login-footer .sep { width: 60px; height: 1px; background: var(--border); margin: 0 auto 8px; }

/* ===== LIVE ROW FLASH (для нових подій з SignalR) ===== */
.row-flash {
    animation: row-flash-anim 1.4s ease-out;
}
@keyframes row-flash-anim {
    0%   { background-color: rgba(16, 185, 129, 0.20); }
    100% { background-color: transparent; }
}

/* ===== MODAL ===== */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(15, 17, 23, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-card {
    width: 560px; max-width: 100%;
    max-height: calc(100vh - 40px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0,0,0,0.6);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
}

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-input.mono { font-family: 'Consolas', 'Menlo', monospace; }

.validation-message { color: var(--danger); font-size: 11.5px; margin-top: 4px; display: block; }

/* ===== BLAZOR ERROR UI ===== */
#blazor-error-ui {
    background: var(--danger); color: white;
    bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,0.3);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .sidebar { width: 200px; }
    .main { margin-left: 200px; }
    .login-card { padding: 28px 22px; }
}
