/* ===============================================
   SIRTW - Sistem Informasi RT/RW
   Design System & Styles
   =============================================== */

/* ---------- CSS Variables ---------- */
:root {
    /* Primary Colors */
    --primary: #6c63ff;
    --primary-light: #8b83ff;
    --primary-dark: #5046e5;
    --primary-bg: rgba(108, 99, 255, 0.08);

    /* Accent Colors */
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #06b6d4;
    --info-bg: rgba(6, 182, 212, 0.1);

    /* Surfaces */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a2e;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
    --bg-sidebar-active: rgba(108, 99, 255, 0.25);
    --bg-input: #f8f9fb;
    --bg-table-stripe: #f8f9fb;
    --bg-topbar: rgba(255, 255, 255, 0.85);

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    --text-sidebar: rgba(255, 255, 255, 0.7);
    --text-sidebar-active: #ffffff;

    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.12);
    --shadow-primary: 0 4px 15px rgba(108, 99, 255, 0.3);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Sizes */
    --sidebar-width: 260px;
    --topbar-height: 64px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
    --bg-body: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-sidebar: #0d0d1a;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
    --bg-input: #16162b;
    --bg-table-stripe: #16162b;
    --bg-topbar: rgba(26, 26, 46, 0.9);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #2d2d4a;
    --border-light: #1e1e35;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.5);
    --primary-bg: rgba(108, 99, 255, 0.15);
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info-bg: rgba(6, 182, 212, 0.15);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

ul,
ol {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    position: relative;
    overflow: hidden;
}

.login-bg-shapes .shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    background: var(--primary);
}

.shape-1 {
    width: 400px;
    height: 400px;
    top: -100px;
    right: -100px;
    animation: float 8s ease-in-out infinite;
}

.shape-2 {
    width: 300px;
    height: 300px;
    bottom: -80px;
    left: -80px;
    animation: float 10s ease-in-out infinite reverse;
    background: var(--accent);
}

.shape-3 {
    width: 200px;
    height: 200px;
    top: 40%;
    left: 60%;
    animation: float 6s ease-in-out infinite;
    background: var(--success);
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-30px) rotate(5deg);
    }
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    z-index: 1;
}

.login-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    animation: slideUp 0.6s var(--transition-slow);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-header .login-logo {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.login-header h1 {
    color: #fff;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-header p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-icon-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 0.95rem;
    transition: var(--transition-base);
}

.input-icon-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.input-icon-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.login-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    margin-top: 16px;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand h2 {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-brand span {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-close {
    display: none;
    color: rgba(255, 255, 255, 0.5);
    padding: 4px;
}

.sidebar-close svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    display: block;
    padding: 12px 12px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.25);
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-sidebar);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
    overflow: hidden;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 600;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.logout-link {
    color: rgba(255, 255, 255, 0.5) !important;
}

.logout-link:hover {
    color: var(--danger) !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

/* ---------- Sidebar Overlay (Mobile) ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ---------- Main Wrapper ---------- */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
}

.sidebar-toggle:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.breadcrumb {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    position: relative;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

[data-theme="light"] .icon-moon {
    display: none;
}

[data-theme="dark"] .icon-sun {
    display: none;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
}

.topbar-user:hover {
    background: var(--primary-bg);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 2px;
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- Stat Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}

.stat-card.primary::after {
    background: var(--primary);
}

.stat-card.success::after {
    background: var(--success);
}

.stat-card.warning::after {
    background: var(--warning);
}

.stat-card.danger::after {
    background: var(--danger);
}

.stat-card.info::after {
    background: var(--info);
}

.stat-card.accent::after {
    background: var(--accent);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-info h3 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-info .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.stat-info .stat-change {
    font-size: 0.75rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.up {
    color: var(--success);
}

.stat-change.down {
    color: var(--danger);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-icon.primary {
    background: var(--primary-bg);
    color: var(--primary);
}

.stat-icon.success {
    background: var(--success-bg);
    color: var(--success);
}

.stat-icon.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-icon.danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-icon.info {
    background: var(--info-bg);
    color: var(--info);
}

.stat-icon.accent {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    transition: var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition-fast);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #0ea572;
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-sm svg {
    width: 15px;
    height: 15px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Tables ---------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-table-stripe);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    font-size: 0.87rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: var(--transition-fast);
}

tbody tr:hover {
    background: var(--primary-bg);
}

.table-actions {
    display: flex;
    gap: 6px;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
    background: var(--bg-card);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---------- Search & Filters ---------- */
.search-filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.filter-select {
    padding: 10px 36px 10px 14px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary {
    background: var(--primary-bg);
    color: var(--primary);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-neutral {
    background: var(--bg-table-stripe);
    color: var(--text-secondary);
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 0;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pagination-buttons {
    display: flex;
    gap: 4px;
}

.pagination-buttons button {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: var(--transition-fast);
}

.pagination-buttons button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-buttons button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination-buttons button:disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s var(--transition-slow);
    box-shadow: var(--shadow-xl);
}

.modal.modal-lg {
    max-width: 720px;
}

.modal.modal-xl {
    max-width: 900px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-close:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 420px;
    animation: slideInRight 0.4s var(--transition-slow);
    pointer-events: auto;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.info {
    border-left-color: var(--info);
}

.toast-icon {
    flex-shrink: 0;
}

.toast-icon svg {
    width: 20px;
    height: 20px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.toast-close {
    color: var(--text-muted);
    padding: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

.toast-exit {
    animation: slideOutRight 0.3s ease forwards;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.85rem;
    max-width: 360px;
    margin: 0 auto;
}

/* ---------- Timeline ---------- */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item.success::before {
    background: var(--success);
    box-shadow: 0 0 0 2px var(--success);
}

.timeline-item.warning::before {
    background: var(--warning);
    box-shadow: 0 0 0 2px var(--warning);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.timeline-content {
    font-size: 0.87rem;
}

/* ---------- Quick Chart (CSS bar chart) ---------- */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 160px;
    padding-top: 10px;
}

.chart-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 100%;
    max-width: 36px;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    transition: height 0.5s var(--transition-slow);
    min-height: 4px;
}

.chart-bar.accent {
    background: linear-gradient(180deg, var(--accent), #2563eb);
}

.chart-bar.success {
    background: linear-gradient(180deg, var(--success), #059669);
}

.chart-bar-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

.chart-bar-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition-fast);
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ---------- Activities List ---------- */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.activity-item:hover {
    background: var(--primary-bg);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg {
    width: 18px;
    height: 18px;
}

.activity-text {
    flex: 1;
    font-size: 0.85rem;
}

.activity-text strong {
    font-weight: 600;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ---------- Print Styles ---------- */
.print-container {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }

    .print-container,
    .print-container * {
        visibility: visible;
    }

    .print-container {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 20px;
    }
}

/* ---------- Calendar Grid ---------- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-header-cell {
    padding: 8px 4px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.calendar-cell {
    padding: 8px;
    min-height: 80px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: var(--transition-fast);
    position: relative;
}

.calendar-cell:hover {
    background: var(--primary-bg);
}

.calendar-cell.other-month {
    opacity: 0.3;
}

.calendar-cell.today {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.calendar-date {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.calendar-event {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--primary-bg);
    color: var(--primary);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.calendar-event.success {
    background: var(--success-bg);
    color: var(--success);
}

.calendar-event.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

.slide-up {
    animation: slideUp 0.5s var(--transition-slow);
}

/* Staggered animation */
.stagger>* {
    animation: slideUp 0.4s var(--transition-slow) backwards;
}

.stagger>*:nth-child(1) {
    animation-delay: 0.05s;
}

.stagger>*:nth-child(2) {
    animation-delay: 0.1s;
}

.stagger>*:nth-child(3) {
    animation-delay: 0.15s;
}

.stagger>*:nth-child(4) {
    animation-delay: 0.2s;
}

.stagger>*:nth-child(5) {
    animation-delay: 0.25s;
}

.stagger>*:nth-child(6) {
    animation-delay: 0.3s;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-toggle {
        display: flex;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-user .user-info {
        display: none;
    }

    .search-filter-bar {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 32px 24px;
    }

    .calendar-cell {
        min-height: 50px;
        padding: 4px;
    }

    .calendar-event {
        display: none;
    }
}

/* ---------- Detail / Info Grid ---------- */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
    font-weight: 600;
}

.info-item span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ---------- Progress bar ---------- */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-table-stripe);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.6s var(--transition-slow);
}

/* Summary Row */
.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--primary-bg);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-weight: 600;
}

/* ---------- Loading Spinner ---------- */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}