/* ============================================================
   DELYAR GLOBAL STYLES
   Warm, calm, Persian-first design baseline
   ============================================================ */

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

/* Base */
html {
    font-size: 100%;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--weight-regular);
    line-height: var(--leading-normal);
    color: var(--color-text-primary);
    background-color: var(--color-bg-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-body);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-snug);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-4);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p {
    margin: 0 0 var(--space-4);
    line-height: var(--leading-relaxed);
}

a {
    color: var(--color-text-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Focus ring — warm rose, visible for accessibility */
:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Inputs */
input, textarea, select {
    font-family: var(--font-body);
    font-size: 16px; /* Prevents iOS auto-zoom */
    color: var(--color-text-primary);
    background-color: var(--color-bg-sunken);
    border: 1.5px solid var(--color-border-default);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    min-height: 52px;
    width: 100%;
    transition: border-color var(--duration-fast) var(--ease-standard),
                box-shadow    var(--duration-fast) var(--ease-standard);
}

input:focus, textarea:focus, select:focus {
    border-color: var(--color-border-focus);
    outline: none;
    box-shadow: 0 0 0 3px var(--color-rose-100);
}

input::placeholder, textarea::placeholder {
    color: var(--color-text-placeholder);
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Page enter animation */
@keyframes page-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-enter {
    animation: page-enter var(--duration-normal) var(--ease-enter) both;
}

/* Blazor reconnection modal */
.components-reconnect-modal {
    background: var(--color-bg-surface) !important;
    border: 1px solid var(--color-neutral-200) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-xl) !important;
    color: var(--color-text-secondary) !important;
    font-family: var(--font-persian) !important;
    font-size: var(--text-sm) !important;
}

/* Blazor error boundary */
.blazor-error-boundary {
    background: var(--color-amber-100);
    border: 1px solid var(--color-amber-200);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    color: var(--color-amber-700);
    font-family: var(--font-body);
    font-size: var(--text-sm);
}

.blazor-error-boundary::after {
    content: "مشکلی پیش آمد. لطفاً صفحه را بارگذاری مجدد کنید.";
}

/* Utility: visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ══════════════════════════════════════════════════════════
   APP SHELL LAYOUT
   Shared by MainLayout and OpsLayout.
   Controls the sidebar + content two-column structure.
   ══════════════════════════════════════════════════════════ */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background-color: var(--color-bg-canvas);
}

.app-body {
    display: flex;
    flex-direction: row;           /* Explicit: sidebar left, content right */
    padding-top: var(--nav-height-top);
    min-height: 100dvh;
}

/* Mobile: sidebar hidden */
.app-sidebar {
    display: none;
}

.app-content {
    flex: 1;
    min-width: 0;
    padding-bottom: calc(var(--nav-height-bottom) + env(safe-area-inset-bottom, 0px));
}

/* Tablet+ (≥768px): sidebar appears at fixed width */
@media (min-width: 768px) {
    .app-sidebar {
        display: flex;
        flex-direction: column;
        width: var(--sidebar-width);
        flex-shrink: 0;
        position: sticky;
        top: var(--nav-height-top);
        height: calc(100dvh - var(--nav-height-top));
        overflow-y: auto;
        background-color: var(--color-bg-sidebar);
        border-inline-end: 1px solid var(--color-border-sidebar);
    }

    .app-content {
        padding-bottom: var(--space-12);
    }
}

/* Ops shell: amber-tinted sidebar distinguishes operations context */
.ops-shell .app-sidebar {
    background-color: #FAF0E4;
    border-inline-end-color: var(--color-amber-200);
}

/* ── Responsive card grid ──────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
}

@media (min-width: 640px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .card-grid { grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
}

/* ── Two-column layout ─────────────────────────────────── */
.layout-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
}

@media (min-width: 900px) {
    .layout-split { grid-template-columns: 1fr 1fr; }
}

/* ── Section headings ──────────────────────────────────── */
.section-heading {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-4);
    line-height: var(--leading-snug);
}

.section-subheading {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-tertiary);
    margin: 0 0 var(--space-3);
    letter-spacing: 0.03em;
}
