/* ===== Self-hosted fonts (no external CDN) ===== */
/* English — Roboto (variable weight) */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/Roboto-Variable.ttf') format('truetype');
}
/* Arabic — Vazirmatn (variable weight) */
@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/Vazirmatn-Variable.ttf') format('truetype');
}
/* Kurdish — NRT */
@font-face {
    font-family: 'NRT';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/NRT-Regular.ttf') format('truetype');
}
@font-face {
    font-family: 'NRT';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/NRT-Bold.ttf') format('truetype');
}

/* ===== PropertyHub Design Tokens ===== */
/* LIGHT THEME (default) — premium neutrals: soft off-white surfaces, white-smoke
   borders, a soft near-black for text/actions (never pure #000). */
:root {
    --font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-ar: 'Vazirmatn', 'Roboto', sans-serif;
    --font-ku: 'NRT', 'Vazirmatn', 'Roboto', sans-serif;
    --font-numeric: 'Roboto', ui-monospace, monospace;

    /* Brand */
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-soft: #EEF0FF;      /* tint for active/hover backgrounds */
    --secondary: #7C3AED;
    --accent: #F97316;
    --pink: #EC4899;
    --success: #10B981;
    --danger: #EF4444;
    --danger-soft: #FEF2F2;
    --warning: #F59E0B;

    /* Neutrals / surfaces */
    --bg: #EEF1F6;                /* soft blue-grey app canvas */
    --surface: #FFFFFF;           /* cards */
    --surface-2: #F7F8FB;         /* subtle inner panels */
    --surface-3: #F1F3F8;
    --border: #ECEEF3;            /* white smoke */
    --border-strong: #E1E5EC;

    /* Text — premium soft black, not #000 */
    --text-primary: #16181D;
    --text-secondary: #6B7280;
    --text-muted: #98A0AC;

    /* Premium black action button */
    --btn-dark: #17181C;
    --btn-dark-hover: #2A2C33;
    --btn-dark-text: #FFFFFF;

    /* Chrome — light, clean sidebar */
    --sidebar-bg: #FFFFFF;
    --sidebar-text: #64748B;
    --sidebar-text-strong: #16181D;
    --sidebar-hover: #F1F3F8;
    --sidebar-border: #ECEEF3;
    --topbar-bg: #FFFFFF;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(16,24,40,0.04), 0 1px 3px rgba(16,24,40,0.06);
    --shadow-md: 0 6px 18px rgba(16,24,40,0.08);
    --shadow-lg: 0 16px 40px rgba(16,24,40,0.14);

    /* Shape */
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    color-scheme: light;

    /* Telerik/Kendo accent → match indigo (default theme ships salmon) */
    --kendo-color-primary: #4F46E5;
    --kendo-color-primary-hover: #4338CA;
    --kendo-color-primary-active: #3730A3;
    --kendo-color-on-primary: #FFFFFF;
    --kendo-border-radius-md: 10px;
}

/* DARK THEME — premium black canvas, soft white text, low-glare borders. */
:root[data-theme="dark"] {
    --primary: #6366F1;
    --primary-dark: #4F46E5;
    --primary-soft: #20223A;
    --secondary: #A78BFA;
    --accent: #FB923C;
    --pink: #F472B6;
    --success: #34D399;
    --danger: #F87171;
    --danger-soft: #2A1B1D;
    --warning: #FBBF24;

    --bg: #0E0F13;               /* premium near-black, not #000 */
    --surface: #17181D;          /* cards */
    --surface-2: #1C1E24;
    --surface-3: #23262E;
    --border: #262A32;           /* subtle low-glare border */
    --border-strong: #333843;

    --text-primary: #F2F3F5;     /* soft white */
    --text-secondary: #A3AAB5;
    --text-muted: #7B828D;

    --btn-dark: #2A2C33;
    --btn-dark-hover: #363943;
    --btn-dark-text: #FFFFFF;

    --sidebar-bg: #101116;
    --sidebar-text: rgba(255,255,255,0.66);
    --sidebar-text-strong: #FFFFFF;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-border: #262A32;
    --topbar-bg: #17181D;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 6px 18px rgba(0,0,0,0.45);
    --shadow-lg: 0 18px 44px rgba(0,0,0,0.55);

    color-scheme: dark;

    /* Telerik/Kendo dark surface mapping so grids, dialogs, dropdowns, pickers
       follow the app theme instead of staying light. */
    --kendo-color-primary: #6366F1;
    --kendo-color-primary-hover: #4F46E5;
    --kendo-color-primary-active: #4338CA;
    --kendo-color-on-primary: #FFFFFF;
    --kendo-color-app-surface: #0E0F13;
    --kendo-color-on-app-surface: #F2F3F5;
    --kendo-color-surface: #1C1E24;
    --kendo-color-surface-alt: #17181D;
    --kendo-color-border: #262A32;
    --kendo-color-border-alt: #333843;
    --kendo-color-base-subtle: #23262E;
    --kendo-color-base-subtle-hover: #2A2E37;
    --kendo-color-base-subtle-active: #313640;
    --kendo-color-base: #1C1E24;
    --kendo-color-base-hover: #23262E;
    --kendo-color-base-active: #2A2E37;
    --kendo-color-base-emphasis: #333843;
    --kendo-color-base-on-subtle: #F2F3F5;
    --kendo-color-on-base: #F2F3F5;
    --kendo-color-base-on-surface: #F2F3F5;
    --kendo-color-subtle: #A3AAB5;
}

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

/* ===== Startup loading indicator ===== */
/* Without these rules the two <svg> circles render as solid black discs ("black hole"). */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #E2E8F0;
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    inset: calc(20vh + 3.25rem) 0 auto 0;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* Language-specific fonts. propertyHubLanguage.apply sets <html lang="…"> so these
   apply across the whole app, including the login screen. */
html[lang="ar"] body, html[lang="ar"] { font-family: var(--font-ar); }
html[lang="ku"] body, html[lang="ku"] { font-family: var(--font-ku); }

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text-strong);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    border-right: 1px solid var(--sidebar-border);
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    color: var(--sidebar-text-strong);
}

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

.sidebar-title {
    font-weight: 600;
    font-size: 1.125rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 1rem 0.75rem 0.375rem;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-strong);
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 35%, transparent);
}

.nav-icon { width: 1.25rem; height: 1.25rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ph-icon { display: block; }
.nav-item .ph-icon { opacity: .85; }
.nav-item.active .ph-icon { opacity: 1; }

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

.user-info { margin-bottom: 0.5rem; }

.user-name {
    font-size: 0.8125rem;
    color: var(--sidebar-text);
}

.logout-btn {
    width: 100%;
    padding: 0.5rem;
    border-radius: 10px;
    border: 1px solid var(--sidebar-border);
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 0.8125rem;
    transition: all 0.15s;
}

.logout-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-strong);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Icon button used in the top bar (theme toggle, etc.) */
.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.25rem;
}

.user-badge {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
}

.page-content {
    flex: 1;
    padding: 1.5rem;
}

.sidebar-overlay { display: none; }
.sidebar-toggle { display: none; }

/* ===== Reusable Components ===== */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card.gradient-indigo {
    background: linear-gradient(135deg, #1E1B4B, #4338CA);
    color: #fff;
}

.stat-card.gradient-purple {
    background: linear-gradient(135deg, #312E81, #7C3AED);
    color: #fff;
}

.stat-card.gradient-pink {
    background: linear-gradient(135deg, #701A75, #DB2777);
    color: #fff;
}

.stat-card.gradient-emerald {
    background: linear-gradient(135deg, #064E3B, #10B981);
    color: #fff;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-card.gradient-indigo .stat-icon,
.stat-card.gradient-purple .stat-icon,
.stat-card.gradient-pink .stat-icon,
.stat-card.gradient-emerald .stat-icon {
    background: rgba(255,255,255,0.15);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.125rem;
}

.stat-card[class*="gradient"] .stat-label { color: rgba(255,255,255,0.7); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-numeric);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active { background: color-mix(in srgb, var(--success) 15%, var(--surface)); color: var(--success); }
.status-badge.inactive { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }
.status-badge.admin { background: color-mix(in srgb, var(--secondary) 16%, var(--surface)); color: var(--secondary); }

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-badge.active .status-dot { background: #10B981; }
.status-badge.inactive .status-dot { background: #EF4444; }
.status-badge.admin .status-dot { background: #7C3AED; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-field {
    margin-bottom: 1rem;
}

.form-field label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
}

.form-field .k-textbox,
.form-field .k-datepicker,
.form-field .k-dropdownlist { width: 100%; }

/* ===== Telerik component sizing / polish ===== */
/* The default Kendo md size renders a bit tight; give inputs, pickers and buttons a
   comfortable height and readable text, and round them to match the design. */
.k-input, .k-picker, .k-button, .k-textbox { font-size: 0.9rem; }

.k-input-md, .k-picker-md, .k-textbox {
    min-height: 40px;
    border-radius: 10px;
}
.k-input-md .k-input-inner,
.k-picker-md .k-input-inner { padding-block: 9px; }

.k-button-md {
    min-height: 40px;
    padding-block: 8px;
    padding-inline: 16px;
    border-radius: 10px;
    font-weight: 600;
}
.k-button-sm { min-height: 32px; border-radius: 8px; font-weight: 600; }

/* Windows / dialogs */
.k-window { border-radius: var(--radius); overflow: hidden; }
.k-window-titlebar { padding: 1rem 1.25rem; font-weight: 700; }
.k-window-content { padding: 1.25rem 1.35rem; }

/* Grid: airier rows, cleaner header */
.k-grid { border-radius: var(--radius); font-size: 0.875rem; overflow: hidden; }
.k-grid .k-table-th, .k-grid th.k-header {
    font-weight: 700;
    background: var(--surface-2);
    padding-block: 12px;
}
.k-grid td { padding-block: 11px; }
.k-grid .k-table-row:hover td { background: var(--surface-2); }

/* Charts inherit the app font */
.k-chart, .k-chart text { font-family: var(--font-sans) !important; }

/* Grid link style used across list pages */
.grid-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.grid-link:hover { text-decoration: underline; }

/* Validation styles */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid red; }
.validation-message { color: red; }

/* Error boundary */
.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 8px;
    margin: 1rem;
}

.blazor-error-boundary::after { content: "An error has occurred."; }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ===== RTL (Kurdish / Arabic) ===== */
.app-layout.rtl { direction: rtl; }

.app-layout.rtl .sidebar {
    left: auto;
    right: 0;
}

.app-layout.rtl .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

.app-layout.rtl .nav-item { flex-direction: row; }

/* Keep numbers in the Latin font even in RTL so prices/counts stay legible */
html[lang="ar"] .stat-value, html[lang="ar"] .project-stat-value,
html[lang="ku"] .stat-value, html[lang="ku"] .project-stat-value {
    font-family: var(--font-numeric);
}

@media (max-width: 1024px) {
    .app-layout.rtl .sidebar { transform: translateX(100%); }
    .app-layout.rtl.mobile-menu-open .sidebar { transform: translateX(0); }
    .app-layout.rtl .main-content { margin-right: 0; }
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .app-layout.mobile-menu-open .sidebar {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .hamburger { display: block; }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page-content { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: stretch; }
}
