/* ============================================================
   Ilmia One — Community Management Dashboard
   Design System & Global Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ── CSS Variables ── */
:root {
    --primary: #5B4CDB;
    --primary-light: #EEF0FF;
    --primary-hover: #4A3CC2;
    --accent-green: #2DBD8F;
    --accent-orange: #F7A23B;
    --accent-red: #F05252;
    --accent-blue: #3B9EF7;
    --bg-base: #F5F6FA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --text-primary: #1A1D2E;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --text-link: #5B4CDB;
    --border: #E8EAF0;
    --border-light: #F0F2F7;
    --shadow-card: 0 1px 4px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
    --shadow-elevated: 0 4px 24px rgba(91,76,219,.12);
    --shadow-sidebar: 2px 0 24px rgba(0,0,0,.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --sidebar-w: 220px;
    --header-h: 64px;
    --font-sans: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'DM Mono', monospace;
    --transition: all .18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ── Layout Shell ── */
.dashboard-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    height: calc(100vh - var(--header-h));
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-sidebar);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14.5px 20px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-logo-icon {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-logo-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    letter-spacing: -.2px;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 18px 20px 6px;
}

.sidebar-nav {
    list-style: none;
    padding: 4px 12px;
    flex: 1;
}

.sidebar-nav-item {
    margin-bottom: 2px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

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

    .sidebar-nav-link.active {
        background: var(--primary-light);
        color: var(--primary);
        font-weight: 600;
    }

    .sidebar-nav-link svg {
        width: 17px;
        height: 17px;
        flex-shrink: 0;
        opacity: .75;
    }

    .sidebar-nav-link.active svg {
        opacity: 1;
    }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-light);
}

.sidebar-signout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    transition: var(--transition);
}

    .sidebar-signout:hover {
        background: #FEF2F2;
        color: var(--accent-red);
    }

    .sidebar-signout svg {
        width: 17px;
        height: 17px;
        flex-shrink: 0;
    }

.sidebar-nav-link svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

/* ── Main Content Area ── */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Header / Topbar ── */
.topbar {
    height: var(--header-h);
    min-height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 90;
}

.topbar-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    letter-spacing: -.2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-icon-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-base);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

    .topbar-icon-btn:hover {
        background: var(--border);
        color: var(--text-primary);
    }

.topbar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    letter-spacing: .5px;
}

/* ── Page Content ── */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
}

.page-welcome {
    margin-bottom: 24px;
}

    .page-welcome h1 {
        font-size: 24px;
        font-weight: 700;
        color: var(--text-primary);
        letter-spacing: -.4px;
        line-height: 1.2;
    }

    .page-welcome p {
        color: var(--text-secondary);
        margin-top: 4px;
        font-size: 14px;
    }

/* ── Grid Layouts ── */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ── Card ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px;
    transition: var(--transition);
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: var(--radius-lg) !important;
    border-top-right-radius: var(--radius-lg) !important;
    /* margin-bottom: 16px; */
}

.card-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.card-link {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

/* ── Quick Action Cards ── */
.quick-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 24px 20px;
    transition: var(--transition);
    cursor: pointer;
}

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

.quick-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

    .quick-card-icon.purple {
        background: var(--primary-light);
        color: var(--primary);
    }

    .quick-card-icon.green {
        background: #ECFDF5;
        color: var(--accent-green);
    }

    .quick-card-icon.orange {
        background: #FFF7ED;
        color: var(--accent-orange);
    }

    .quick-card-icon.blue {
        background: #EFF6FF;
        color: var(--accent-blue);
    }

    .quick-card-icon.red {
        background: #FEF2F2;
        color: var(--accent-red);
    }

    .quick-card-icon svg {
        width: 22px;
        height: 22px;
    }

.quick-card h3 {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.quick-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.quick-card-action {
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
}

/* ── Stat Cards ── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.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-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.5px;
    line-height: 1;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    margin-top: 5px;
}

    .stat-badge.up {
        background: #ECFDF5;
        color: var(--accent-green);
    }

    .stat-badge.down {
        background: #FEF2F2;
        color: var(--accent-red);
    }

/* ── Empty State ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    gap: 10px;
}

    .empty-state svg {
        width: 36px;
        height: 36px;
        opacity: .4;
    }

    .empty-state p {
        font-size: 14px;
        font-weight: 500;
        color: var(--text-secondary);
    }

    .empty-state span {
        font-size: 12.5px;
    }

/* ── Section Spacer ── */
.section {
    margin-bottom: 20px;
}

/* ── Activity List ── */
.activity-list {
    list-style: none;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

    .activity-dot.purple {
        background: var(--primary);
    }

    .activity-dot.green {
        background: var(--accent-green);
    }

    .activity-dot.orange {
        background: var(--accent-orange);
    }

    .activity-dot.red {
        background: var(--accent-red);
    }

    .activity-dot.blue {
        background: var(--accent-blue);
    }

.activity-info {
    flex: 1;
}

.activity-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.activity-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.activity-time {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Visitor Log ── */
.visitor-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

    .visitor-row:last-child {
        border-bottom: none;
    }

.visitor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.visitor-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.visitor-unit {
    font-size: 12px;
    color: var(--text-secondary);
}

.visitor-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

.visitor-actions {
    display: flex;
    gap: 6px;
}

/* ── Badges / Status Pills ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

    .badge.success {
        background: #ECFDF5;
        color: #059669;
    }

    .badge.warning {
        background: #FFF7ED;
        color: #D97706;
    }

    .badge.danger {
        background: #FEF2F2;
        color: #DC2626;
    }

    .badge.info {
        background: #EFF6FF;
        color: #2563EB;
    }

    .badge.neutral {
        background: var(--bg-base);
        color: var(--text-secondary);
    }

/* ── Buttons ── */
.btn {
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

    .btn-primary:hover {
        background: var(--primary-hover);
        box-shadow: 0 4px 12px rgba(91,76,219,.35);
    }

.btn-secondary {
    background: var(--primary-light);
    color: var(--primary);
}

    .btn-secondary:hover {
        background: #DDE0FB;
    }

.btn-success {
    background: #ECFDF5;
    color: #059669;
}

    .btn-success:hover {
        background: #D1FAE5;
    }

.btn-danger {
    background: #FEF2F2;
    color: #DC2626;
}

    .btn-danger:hover {
        background: #FEE2E2;
    }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

    .btn-ghost:hover {
        background: var(--bg-base);
        color: var(--text-primary);
    }

.btn-sm {
    padding: 5px 11px;
    font-size: 12px;
}

.btn-lg {
    padding: 11px 22px;
    font-size: 14.5px;
}

.btn svg {
    width: 15px;
    height: 15px;
}

/* ── Table ── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 14px;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

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

tbody tr:hover {
    background: #FAFBFF;
}

/* ── Alert ── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid transparent;
    margin-bottom: 10px;
    font-size: 13.5px;
}

    .alert:last-child {
        margin-bottom: 0;
    }

    .alert svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        margin-top: 1px;
    }

    .alert.warning {
        background: #FFFBEB;
        border-color: var(--accent-orange);
        color: #92400E;
    }

    .alert.danger {
        background: #FFF5F5;
        border-color: var(--accent-red);
        color: #9B1C1C;
    }

    .alert.info {
        background: #EFF6FF;
        border-color: var(--accent-blue);
        color: #1E40AF;
    }

    .alert.success {
        background: #ECFDF5;
        border-color: var(--accent-green);
        color: #065F46;
    }

.alert-title {
    font-weight: 700;
    margin-bottom: 2px;
}

.alert-desc {
    font-size: 12.5px;
    opacity: .85;
}

/* ── Chart Placeholder ── */
.chart-placeholder {
    width: 100%;
    height: 180px;
    background: var(--bg-base);
    border-radius: var(--radius-md);
    border: 2px dashed var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 6px;
    font-size: 13px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 100px;
    padding: 0 10px;
}

.chart-bar {
    flex: 1;
    border-radius: 6px 6px 0 0;
    background: var(--primary-light);
    position: relative;
    transition: var(--transition);
    min-width: 18px;
}

    .chart-bar:hover {
        background: var(--primary);
    }

    .chart-bar.active {
        background: var(--primary);
    }

.chart-labels {
    display: flex;
    gap: 6px;
    padding: 0 10px;
}

.chart-label {
    flex: 1;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 18px;
}

/* ── Donut Chart ── */
.donut-wrap {
    display: flex;
    align-items: center;
    gap: 24px;
}

.donut-svg {
    flex-shrink: 0;
}

.donut-legend {
    flex: 1;
}

.donut-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

    .donut-item:last-child {
        margin-bottom: 0;
    }

.donut-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.donut-item-label {
    color: var(--text-secondary);
    flex: 1;
}

.donut-item-value {
    font-weight: 700;
    color: var(--text-primary);
}

/* ── Guard-specific ── */
.checkin-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.gate-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.gate-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

    .gate-dot.open {
        background: var(--accent-green);
        box-shadow: 0 0 0 0 rgba(45,189,143,.4);
    }

    .gate-dot.closed {
        background: var(--accent-red);
        box-shadow: 0 0 0 0 rgba(240,82,82,.4);
    }

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(45,189,143,.4);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(45,189,143,0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(45,189,143,0);
    }
}

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

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-w: 0px;
    }

    .sidebar {
        display: none;
    }

    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: 16px;
    }
}

/* ── Utilities ── */
.mt-4 {
    margin-top: 4px;
}

.mt-8 {
    margin-top: 8px;
}

.mt-16 {
    margin-top: 16px;
}

.mt-20 {
    margin-top: 20px;
}

.mt-24 {
    margin-top: 24px;
}

.mb-4 {
    margin-bottom: 4px;
}

.mb-8 {
    margin-bottom: 8px;
}

.mb-16 {
    margin-bottom: 16px;
}

.mb-20 {
    margin-bottom: 20px;
}

.flex {
    display: flex;
}

.flex-1 {
    flex: 1;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-8 {
    gap: 8px;
}

.gap-12 {
    gap: 12px;
}

.gap-16 {
    gap: 16px;
}

.font-bold {
    font-weight: 700;
}

.text-sm {
    font-size: 12.5px;
}

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

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

.w-full {
    width: 100%;
}

/* Override Bootstrap/Blazor defaults */
.dashboard-shell .btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

.dashboard-shell .content {
    padding-top: 0 !important;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.member-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    transition: transform 0.2s;
}

    .member-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

.btn-add {
    background: #5a67d8;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
}
