/**
 * Asset Sentinel - Slate Design System
 * Neutral gray + teal accent, flat shadows, dark/light via data-theme
 */

:root {
    --bg-primary:   #141418;
    --bg-secondary: #1c1c22;
    --bg-tertiary:  #26262e;
    --bg-card:      #1e1e26;
    --bg-border:    #2e2e38;

    --text-primary:   #e8e8ed;
    --text-secondary: #a0a0ab;
    --text-muted:     #6b6b78;
    --text-inverse:   #141418;

    --accent:        #2dd4bf;
    --accent-hover:  #14b8a6;
    --accent-light:  rgba(45, 212, 191, 0.12);
    --accent-subtle: rgba(45, 212, 191, 0.06);
    --primary:       #2dd4bf;
    --primary-hover: #14b8a6;
    --primary-light: rgba(45, 212, 191, 0.12);

    --success: #34d399;
    --warning: #fbbf24;
    --danger:  #f87171;
    --info:    #38bdf8;

    --shadow-sm:  0 1px  2px rgba(0,0,0,0.35);
    --shadow-md:  0 2px  6px rgba(0,0,0,0.40);
    --shadow-lg:  0 4px 14px rgba(0,0,0,0.45);
    --shadow-xl:  0 8px 28px rgba(0,0,0,0.50);

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
}

[data-theme="light"] {
    --bg-primary:   #f4f4f7;
    --bg-secondary: #eaeaef;
    --bg-tertiary:  #ffffff;
    --bg-card:      #ffffff;
    --bg-border:    #d4d4da;

    --text-primary:   #1a1a1f;
    --text-secondary: #4a4a55;
    --text-muted:     #8a8a95;
    --text-inverse:   #f4f4f7;

    --accent:        #0d9488;
    --accent-hover:  #0f766e;
    --accent-light:  rgba(13, 148, 136, 0.10);
    --accent-subtle: rgba(13, 148, 136, 0.04);
    --primary:       #0d9488;
    --primary-hover: #0f766e;
    --primary-light: rgba(13, 148, 136, 0.10);

    --success: #059669;
    --warning: #d97706;
    --danger:  #dc2626;
    --info:    #0284c7;

    --shadow-sm:  0 1px  2px rgba(0,0,0,0.06);
    --shadow-md:  0 2px  6px rgba(0,0,0,0.08);
    --shadow-lg:  0 4px 14px rgba(0,0,0,0.10);
    --shadow-xl:  0 8px 28px rgba(0,0,0,0.12);
}

/* Base */

* {
    transition: background-color 0.25s ease, color 0.25s ease,
                border-color 0.25s ease, box-shadow 0.25s ease;
}

html {
    scroll-behavior: smooth;
    color: var(--text-primary);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Sidebar */

.sidebar {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--bg-border);
    box-shadow: var(--shadow-md);
    width: var(--sidebar-width);
    transition: width 0.3s ease, transform 0.3s ease;
}

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

.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .user-info-text,
.sidebar.collapsed .admin-label {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .user-section {
    padding: 0.75rem;
    justify-content: center;
}

.sidebar-toggle {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 1px solid var(--bg-border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    z-index: 100;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    color: var(--accent);
    background-color: var(--bg-tertiary);
}

.sidebar-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Main Content */

.main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
}

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

.top-bar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-border);
    box-shadow: var(--shadow-sm);
}

/* Card */

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

/* Stat Card */

.stat-card {
    position: relative;
    background-color: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-light);
    color: var(--accent);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

/* Navigation */

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all 0.25s ease;
    gap: 0.75rem;
    background-color: transparent;
}

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

.nav-link.active {
    background-color: var(--accent-light);
    color: var(--accent);
}

.nav-link.active svg { color: var(--accent); }

.nav-link svg {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.25s ease;
}

/* Form Elements */

.input-field {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.25s ease;
    box-shadow: none;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

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

select.input-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b6b78'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

label,
.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Buttons */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--accent);
    color: var(--text-inverse);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--bg-border);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: var(--bg-card);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--danger);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
    border: none;
    cursor: pointer;
}

.btn-danger:hover {
    filter: brightness(1.1);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all 0.25s ease;
    border: 1px solid var(--bg-border);
    cursor: pointer;
}

.btn-icon:hover {
    color: var(--text-primary);
    background-color: var(--bg-card);
    transform: translateY(-1px);
}

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

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-success {
    background-color: rgba(52, 211, 153, 0.15);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.25);
}

.badge-warning {
    background-color: rgba(251, 191, 36, 0.15);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.25);
}

.badge-danger {
    background-color: rgba(248, 113, 113, 0.15);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.25);
}

.badge-info {
    background-color: rgba(56, 189, 248, 0.15);
    color: var(--info);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.badge-critical {
    background-color: rgba(248, 113, 113, 0.20);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.35);
}

.badge-high {
    background-color: rgba(251, 146, 60, 0.20);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.35);
}

.badge-medium {
    background-color: rgba(251, 191, 36, 0.20);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.35);
}

.badge-low {
    background-color: rgba(52, 211, 153, 0.20);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.35);
}

/* Severity / Status */

.severity-critical { color: var(--danger); }
.severity-high     { color: #fb923c; }
.severity-medium   { color: var(--warning); }
.severity-low      { color: var(--success); }

.status-open        { color: var(--danger); }
.status-in_progress { color: var(--warning); }
.status-resolved    { color: var(--success); }

/* Tables */

.table-container {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

table th {
    font-weight: 600;
    text-align: left;
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    padding: 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--bg-border);
}

table td {
    padding: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--bg-border);
}

table tbody tr {
    transition: background-color 0.2s ease;
    background-color: var(--bg-card);
}

table tbody tr:hover {
    background-color: var(--bg-tertiary);
}

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

/* Toast */

.toast {
    display: flex;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    background-color: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    max-width: 420px;
    animation: slideIn 0.3s ease;
}

.toast p { color: var(--text-primary); }

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info    { border-left: 4px solid var(--info); }

@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; }
}

/* Modal */

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.60);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 50;
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--bg-border);
    background-color: var(--bg-tertiary);
}

.modal-header h3 {
    color: var(--text-primary);
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
    color: var(--text-primary);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--bg-border);
    background-color: var(--bg-tertiary);
}

/* Progress Bar */

.progress-bar {
    height: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}

/* Chart Container */

.chart-container {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

/* Dropdown */

.dropdown-item {
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: var(--bg-tertiary);
}

/* Scrollbar */

::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* User Avatar */

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-weight: 600;
}

/* Typography */

.page-title {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 700;
}

.section-title {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state svg {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Theme-aware utilities */

.text-primary-theme   { color: var(--text-primary); }
.text-secondary-theme { color: var(--text-secondary); }
.text-muted-theme     { color: var(--text-muted); }

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

.border-theme { border-color: var(--bg-border); }
.divide-theme > * + * { border-color: var(--bg-border); }

/* Hover utilities */
.hover-bg-tertiary:hover  { background-color: var(--bg-tertiary); }
.hover-bg-secondary:hover { background-color: var(--bg-secondary); }
.hover-text-primary:hover { color: var(--text-primary); }

/* Modal theme-aware overrides (for inline <style> blocks in templates) */
.modal-dialog   { background: var(--bg-card); border-color: var(--bg-border); }
.modal-title    { color: var(--text-primary); }
.modal-close    { color: var(--text-muted); }
.modal-close:hover { color: var(--text-primary); }
.modal-header   { border-bottom-color: var(--bg-border); }
.modal-body     { color: var(--text-primary); }
.progress-bar-mini { background: var(--bg-tertiary); }
.dropdown-content  { background: var(--bg-card); border-color: var(--bg-border); }
.dropdown-item     { color: var(--text-secondary); }
.dropdown-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* Links */

a {
    color: var(--accent);
    transition: color 0.25s ease;
}

a:hover {
    color: var(--accent-hover);
}

/* Accessibility */

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Responsive */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 100;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content,
    .main-content.sidebar-collapsed { margin-left: 0; }
    .sidebar-toggle { display: none; }
}

@media (max-width: 768px) {
    .stat-card { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
    .btn-primary,
    .btn-secondary,
    .btn-danger { padding: 0.625rem 1rem; }
    .page-title { font-size: 1.5rem; }
    table th,
    table td { padding: 0.75rem; font-size: 0.8125rem; }
}

/* Print */

@media print {
    .sidebar, .top-bar, .btn-primary, .btn-secondary, .btn-danger {
        display: none !important;
    }
    .main-content { margin-left: 0 !important; }
    body { background: white !important; color: black !important; }
}
