@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --secondary: #7C3AED;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1E293B;
    --bg-hover: #F1F5F9;

    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --text-white: #FFFFFF;

    --border: #E2E8F0;
    --border-light: #F1F5F9;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --priority-high: #FEE2E2;
    --priority-high-border: #FCA5A5;
    --priority-high-text: #DC2626;
    --priority-normal: #FEF9C3;
    --priority-normal-border: #FDE68A;
    --priority-normal-text: #CA8A04;
    --priority-low: #DCFCE7;
    --priority-low-border: #86EFAC;
    --priority-low-text: #16A34A;

    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover { color: var(--primary-dark); }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

input, textarea, select {
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

img { max-width: 100%; }

/* ===== Utility ===== */
.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(79,70,229,0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #DC2626; }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-primary);
    background: white;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

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='%2364748B'%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: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ===== Cards/Panels ===== */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.panel-body {
    padding: 24px;
}

/* ===== Top Navigation ===== */
.topnav {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.topnav-brand img {
    height: 32px;
    width: auto;
}

.topnav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topnav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    position: relative;
}

.topnav-user:hover { background: var(--bg-hover); }

.topnav-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.topnav-user-info {
    line-height: 1.3;
}

.topnav-user-info .name {
    font-size: 14px;
    font-weight: 600;
}

.topnav-user-info .role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* User dropdown */
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 6px;
    display: none;
    z-index: 200;
}

.user-dropdown.show { display: block; }

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.user-dropdown a:hover { background: var(--bg-hover); }

.user-dropdown a.danger { color: var(--danger); }

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    height: 48px;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius);
    margin-top: 8px;
}

.login-error {
    background: #FEF2F2;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #FECACA;
    display: none;
}

.login-error.show { display: block; }

/* ===== Search Bar ===== */
.search-container {
    position: relative;
    max-width: 400px;
}

.search-container i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-container input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg);
}

.search-container input:focus {
    border-color: var(--primary);
    background: white;
}

.search-filters {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip:hover, .filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-high {
    background: var(--priority-high);
    color: var(--priority-high-text);
    border: 1px solid var(--priority-high-border);
}

.badge-normal {
    background: var(--priority-normal);
    color: var(--priority-normal-text);
    border: 1px solid var(--priority-normal-border);
}

.badge-low {
    background: var(--priority-low);
    color: var(--priority-low-text);
    border: 1px solid var(--priority-low-border);
}

.badge-active {
    background: #DCFCE7;
    color: #16A34A;
}

.badge-suspended {
    background: #FEE2E2;
    color: #DC2626;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 20px;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: var(--transition-slow);
}

.modal-overlay.show .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    border: none;
}
.modal-close:hover { background: var(--bg-hover); }

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== Table ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
}

table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg);
}

table tr:hover td { background: var(--bg-hover); }

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: toastIn 0.3s ease;
    color: white;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

/* ===== Stat Cards ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-top: 4px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.stat-card .stat-icon.blue { background: #EEF2FF; color: var(--primary); }
.stat-card .stat-icon.green { background: #ECFDF5; color: var(--success); }
.stat-card .stat-icon.yellow { background: #FFFBEB; color: var(--warning); }
.stat-card .stat-icon.red { background: #FEF2F2; color: var(--danger); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .topnav { padding: 0 16px; }
    .topnav-user-info { display: none; }
    .login-container { padding: 32px 24px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-body { padding: 16px; }
    .modal { max-width: 100%; margin: 10px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .topnav-brand span { display: none; }
}
