@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

@font-face {
    font-family: "B Nazanin";
    src: url("font/BNazanin.ttf") format("truetype");
}

:root {
    --bg-main: #f3f6fb;
    --bg-soft: #eef3fb;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --border: #dbe4f0;
    --border-strong: #c9d7eb;
    --text-main: #152238;
    --text-muted: #4b5f7c;
    --primary: #0f6cbf;
    --primary-strong: #094f8d;
    --accent: #ff8b37;
    --success: #18a574;
    --danger: #d84b4b;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 6px 18px rgba(16, 58, 112, 0.08);
    --shadow-md: 0 14px 36px rgba(16, 58, 112, 0.12);
}

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

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "B Nazanin", Tahoma, sans-serif;
    background: radial-gradient(circle at top right, #ffffff 0%, var(--bg-main) 52%, #e8eef8 100%);
    color: var(--text-main);
    direction: rtl;
}

a,
li.ant-menu-item a {
    text-decoration: none;
}

h1:focus {
    outline: none;
}

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

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem rgba(15, 108, 191, 0.3);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: #fff4cf;
    bottom: 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
    display: none;
    left: 0;
    padding: 0.8rem 1.2rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    left: 1rem;
    top: 0.4rem;
}

.blazor-error-boundary {
    background: #b32121;
    color: #fff;
    padding: 1rem 1rem 1rem 3.7rem;
}

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

/* Main navigation layout */
.main-nav-layout {
    min-height: 100vh;
    background: transparent;
}

.main-nav-header {
    height: auto;
    line-height: normal;
    background: linear-gradient(90deg, #0a4a7e 0%, #0f6cbf 100%) !important;
    padding: 0 14px;
    box-shadow: 0 8px 22px rgba(13, 70, 121, 0.28);
    position: sticky;
    top: 0;
    z-index: 70;
}

.main-nav-inner {
    display: flex;
    align-items: center;
    justify-content: start;
    gap: 10px;
    min-height: 72px;
}

.main-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    min-width: 240px;
}

.mobile-menu-btn {
    display: none !important;
    color: #fff !important;
    border: 0 !important;
}

.main-nav-brand img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
}

.main-nav-brand strong {
    display: block;
    font-size: 1rem;
    line-height: 1.1;
}

.main-nav-brand span {
    display: block;
    opacity: 0.9;
    font-size: 0.8rem;
}

.desktop-menu-wrap {
    flex: 1;
    min-width: 0;
}

.desktop-nav-menu {
    background: transparent !important;
    border-bottom: 0 !important;
}

.desktop-nav-menu.ant-menu-horizontal > .ant-menu-item {
    color: rgba(255, 255, 255, 0.92) !important;
    border-bottom: 3px solid transparent !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.desktop-nav-menu.ant-menu-horizontal > .ant-menu-item:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

.desktop-nav-menu.ant-menu-horizontal > .ant-menu-item-selected {
    color: #fff !important;
    border-bottom-color: var(--accent) !important;
    background: rgba(255, 255, 255, 0.14) !important;
}

.main-nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    white-space: nowrap;
    margin-inline-start: auto;
}

.main-nav-user .ant-avatar {
    background-color: rgba(255, 255, 255, 0.22);
}

.mobile-nav-menu .ant-menu-item {
    border-radius: 10px;
    margin: 3px 0;
}

.main-nav-content {
    margin: 0;
    padding: 14px;
}

.main-nav-page {
    min-height: calc(100vh - 144px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}

/* Generic page building blocks */
.page-shell {
    display: grid;
    gap: 14px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.1;
}

.page-subtitle {
    margin: 3px 0 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.surface-card {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
}

.filter-panel {
    background: linear-gradient(180deg, #fafdff 0%, #f2f7ff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.field-grid > * {
    min-width: 0 !important;
    width: 100% !important;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-shell {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    overflow: hidden;
}

.table-shell .ant-table-wrapper {
    overflow: auto;
}

.table-shell .ant-table {
    min-width: 760px;
}

.table-shell .ant-table-thead > tr > th {
    background: #f2f7ff;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.table-shell .ant-table-cell {
    white-space: nowrap;
}

.table-shell .btn,
.table-shell .ant-btn {
    margin-inline-start: 4px;
    margin-block: 2px;
}

/* Demands table: prevent text overlap between adjacent columns */
.demands-table-shell .ant-table-cell {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
    line-height: 1.5;
}

.demands-table-shell .ant-table-cell a,
.demands-table-shell .ant-table-cell span {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.demands-table-shell .editable-cell-value-wrap {
    min-height: 32px;
    display: flex;
    align-items: center;
}

.form-shell {
    max-width: 780px;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    padding: 14px;
}

.form-shell .ant-form-item {
    margin-bottom: 12px;
}

.form-shell .ant-input,
.form-shell .ant-input-number,
.form-shell .ant-select {
    width: 100%;
}

.mobile-full-width,
.mobile-full-width .ant-select,
.mobile-full-width .ant-input,
.mobile-full-width .ant-input-number {
    width: 100%;
}

/* Ant Design component polish */
.ant-collapse {
    border-radius: var(--radius-md);
    overflow: hidden;
    border-color: var(--border);
}

.ant-collapse-content-box {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ant-collapse-content-box > * {
    min-width: 160px;
}

.ant-select,
.ant-input,
.ant-input-number,
.ant-picker {
    max-width: 100%;
}

.ant-btn {
    border-radius: 10px;
}

.ant-modal-content {
    border-radius: var(--radius-md);
}

.ant-tabs-nav {
    margin-bottom: 10px !important;
}

.ant-tabs-tab {
    border-radius: 10px 10px 0 0 !important;
}

.ant-card,
.card {
    border-radius: var(--radius-md);
    border-color: var(--border);
}

/* Charts and specialty blocks */
.chart-container {
    display: grid;
    gap: 14px;
}

.chart-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm) !important;
}

.chart-card-header-primary {
    background: linear-gradient(135deg, #1e87de 0%, #12599c 100%);
    color: #fff;
    padding: 0.9rem 1rem;
}

.chart-card-header-secondary {
    background: linear-gradient(135deg, #1aa686 0%, #0e7c63 100%);
    color: #fff;
    padding: 0.75rem 1rem;
}

.chart-inner-card {
    border-radius: var(--radius-sm);
}

.billTable,
.billTable > td {
    background-color: #dff4ec !important;
}

.editable-cell {
    position: relative;
}

.editable-cell-value-wrap {
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 8px;
}

.editable-row:hover .editable-cell-value-wrap {
    border: 1px solid #d9d9d9;
}

/* Login */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 10% 20%, rgba(15, 108, 191, 0.18), transparent 35%),
        radial-gradient(circle at 90% 15%, rgba(255, 139, 55, 0.18), transparent 35%),
        linear-gradient(170deg, #f8fbff 0%, #edf3fb 100%);
}

.login-card {
    width: min(420px, 100%);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    padding: 24px;
}

.login-logo {
    width: 74px;
    height: 74px;
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
}

.login-card .form-control {
    border-radius: 10px;
    min-height: 44px;
}

.login-card .btn {
    min-height: 46px;
    border-radius: 11px;
}

/* Chat */
.chat-shell {
    display: grid;
    gap: 10px;
}

.chat-messages {
    max-height: 52vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    background: #f9fbff;
}

.chat-composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.chat-composer input {
    min-height: 44px;
}

/* Responsive */
@media (max-width: 992px) {
    .main-nav-header {
        padding: 0 10px;
    }

    .main-nav-brand {
        min-width: 170px;
    }
}

@media (max-width: 768px) {
    .main-nav-header {
        position: static;
    }

    .main-nav-inner {
        min-height: 64px;
    }

    .mobile-menu-btn {
        display: inline-flex !important;
    }

    .desktop-menu-wrap {
        display: none;
    }

    .main-nav-brand {
        min-width: 0;
        flex: 1;
    }

    .main-nav-brand span {
        display: none;
    }

    .main-nav-user span {
        display: none;
    }

    .main-nav-content {
        padding: 10px;
    }

    .main-nav-page {
        min-height: auto;
        padding: 10px;
        border-radius: 14px;
    }

    .page-title {
        font-size: 1.1rem;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .table-shell .ant-table {
        min-width: 620px;
    }

    .ant-collapse-content-box > * {
        flex: 1 1 100%;
    }

    .chat-messages {
        max-height: 44vh;
    }

    .login-shell {
        padding: 12px;
    }

    .login-card {
        padding: 16px;
    }
}

@media (max-width: 420px) {
    .main-nav-page {
        padding: 8px;
    }

    .page-actions,
    .inline-actions {
        width: 100%;
    }

    .page-actions > *,
    .inline-actions > * {
        flex: 1 1 100%;
        min-width: 0;
    }
}
