/* =============================================
   EGRN Bot Admin — Design System
   Aesthetic: "Precision Dashboard"
   Fonts: Outfit (headings) + DM Sans (body)
   ============================================= */

:root {
    --color-bg:          #f1f5f9;
    --color-surface:     #ffffff;
    --color-surface-alt: #f8fafc;
    --color-border:      #e2e8f0;
    --color-border-light:#f1f5f9;

    --color-sidebar:     #0f172a;

    --color-primary:     #2563eb;
    --color-primary-hover:#1d4ed8;
    --color-primary-soft: rgba(37,99,235,0.08);
    --color-primary-glow: rgba(37,99,235,0.25);

    --color-success:     #059669;
    --color-success-soft: rgba(5,150,105,0.08);
    --color-success-glow: rgba(5,150,105,0.25);

    --color-danger:      #dc2626;
    --color-danger-soft:  rgba(220,38,38,0.08);
    --color-danger-glow:  rgba(220,38,38,0.25);

    --color-warning:     #d97706;
    --color-warning-soft: rgba(217,119,6,0.08);
    --color-warning-glow: rgba(217,119,6,0.25);

    --color-amber:       #f59e0b;
    --color-rose:        #f43f5e;
    --color-indigo:      #6366f1;
    --color-primary-light: #93c5fd;

    --color-text:        #0f172a;
    --color-text-secondary: #64748b;
    --color-text-tertiary:  #94a3b8;
    --color-text-inverse:   #f8fafc;

    --font-display: 'Outfit', system-ui, sans-serif;
    --font-body:    'DM Sans', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-colored: 0 4px 14px -2px;

    --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;

    /* Bootstrap overrides — синхронизация с дизайн-системой */
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-success: #059669;
    --bs-success-rgb: 5, 150, 105;
    --bs-danger: #dc2626;
    --bs-danger-rgb: 220, 38, 38;
    --bs-warning: #d97706;
    --bs-warning-rgb: 217, 119, 6;
    --bs-info: #6366f1;
    --bs-info-rgb: 99, 102, 241;
    --bs-secondary: #64748b;
    --bs-secondary-rgb: 100, 116, 139;
}

/* === Base === */

html, body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Отключаем плавный скролл — Bootstrap reboot ставит :root { scroll-behavior: smooth },
   из-за чего enhanced navigation Blazor визуально анимирует прыжок наверх
   при переходе по ссылкам между страницами (например, кнопка «Подробнее»). */
html {
    scroll-behavior: auto;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

code, pre, .font-mono { font-family: var(--font-mono); }

a, .btn-link {
    color: var(--color-primary);
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--color-primary-hover);
}

/* === Buttons === */

.btn {
    font-family: var(--font-display);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    transition: all var(--duration-normal) var(--ease-out);
    letter-spacing: 0.01em;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary, .btn-primary:active, .btn-primary:visited {
    color: #fff;
    background: var(--color-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--color-primary-hover);
    box-shadow: var(--shadow-colored) var(--color-primary-glow);
    color: #fff;
}

.btn-outline-primary {
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
    background: transparent;
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-colored) var(--color-primary-glow);
}

.btn-success, .btn-success:active, .btn-success:visited {
    color: #fff;
    background: var(--color-success);
}
.btn-success:hover, .btn-success:focus {
    background: #047857;
    box-shadow: var(--shadow-colored) var(--color-success-glow);
    color: #fff;
}

.btn-danger, .btn-danger:active, .btn-danger:visited {
    color: #fff;
    background: var(--color-danger);
}
.btn-danger:hover, .btn-danger:focus {
    background: #b91c1c;
    box-shadow: var(--shadow-colored) var(--color-danger-glow);
    color: #fff;
}

.btn-outline-danger {
    color: var(--color-danger);
    border: 1.5px solid var(--color-danger);
    background: transparent;
}
.btn-outline-danger:hover, .btn-outline-danger:focus {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: white;
    box-shadow: var(--shadow-colored) var(--color-danger-glow);
}

.btn-secondary, .btn-secondary:active, .btn-secondary:visited {
    color: var(--color-text);
    background: var(--color-border);
}
.btn-secondary:hover, .btn-secondary:focus {
    background: #cbd5e1;
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.btn-outline-secondary {
    color: var(--color-text-secondary);
    border: 1.5px solid var(--color-border);
    background: transparent;
}
.btn-outline-secondary:hover, .btn-outline-secondary:focus {
    background: var(--color-surface);
    border-color: #cbd5e1;
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.btn-warning, .btn-warning:active, .btn-warning:visited {
    color: #fff;
    background: var(--color-warning);
}
.btn-warning:hover, .btn-warning:focus {
    background: #b45309;
    box-shadow: var(--shadow-colored) var(--color-warning-glow);
    color: #fff;
}

.btn-outline-warning {
    color: var(--color-warning);
    border: 1.5px solid var(--color-warning);
    background: transparent;
}
.btn-outline-warning:hover, .btn-outline-warning:focus {
    background: var(--color-warning);
    border-color: var(--color-warning);
    color: white;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-check-input:focus {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

/* === Content === */

.content {
    padding-top: 1.25rem;
    padding-bottom: 3rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 1.25rem;
}

h1:focus {
    outline: none;
}

/* === Cards === */

.card {
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--color-surface);
    transition: box-shadow var(--duration-normal) var(--ease-out);
}

a > .card:hover,
.card-clickable:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: #eff6ff;
    color: var(--color-text);
    border: none;
    border-bottom: 1px solid #dbeafe;
    padding: 1rem 1.25rem;
    font-family: var(--font-display);
}

.card-header h4, .card-header h5 {
    color: var(--color-primary-hover, #1d4ed8);
    margin: 0;
    font-family: var(--font-display);
    letter-spacing: -0.01em;
}

.card-body {
    padding: 1.25rem;
}

/* === Tables === */

.table {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table thead {
    background: #dbeafe;
}

.table thead th {
    border: none;
    border-bottom: 2px solid #bfdbfe;
    background-color: #dbeafe !important;
    font-family: var(--font-display);
    font-weight: 600;
    color: #1e3a5f !important;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Bootstrap .table-dark thead — переопределяем под дизайн-систему */
.table-dark,
.table thead.table-dark,
thead.table-dark {
    background: #dbeafe !important;
    --bs-table-bg: #dbeafe;
    --bs-table-color: #1e3a5f;
}

.table-dark th,
.table thead.table-dark th,
thead.table-dark th {
    background: #dbeafe !important;
    color: #1e3a5f !important;
    border-color: #bfdbfe !important;
}

.table tbody tr {
    transition: background-color var(--duration-fast) var(--ease-out);
    border-bottom: 1px solid var(--color-border-light);
}

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

.table tbody tr:hover {
    background-color: var(--color-primary-soft);
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    color: var(--color-text);
    border: none;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--color-surface-alt);
}

.table-striped > tbody > tr:nth-of-type(odd):hover > * {
    background-color: var(--color-primary-soft);
}

/* === Breadcrumb === */

.breadcrumb {
    font-family: var(--font-display);
    font-size: 0.875rem;
}

.breadcrumb-item a {
    color: var(--color-primary);
}

.breadcrumb-item.active {
    color: var(--color-text-secondary);
}

/* === Badges === */

.badge {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.35em 0.65em;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.badge.bg-primary {
    background: var(--color-primary) !important;
}

.badge.bg-success {
    background: var(--color-success) !important;
}

.badge.bg-danger {
    background: var(--color-danger) !important;
}

.badge.bg-warning {
    background: var(--color-warning) !important;
    color: #fff !important;
}

.badge.bg-info {
    background: var(--color-indigo) !important;
    color: #fff !important;
}

/* === Dashboard stat cards === */

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

@media (max-width: 1200px) {
    .dashboard-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .dashboard-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .dashboard-cards { grid-template-columns: 1fr; }
}

.stat-card {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
    transition: transform var(--duration-normal) var(--ease-spring),
                box-shadow var(--duration-normal) var(--ease-out);
}

/* Декоративная полоска сверху */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.4);
}

/* Фоновый паттерн — точки */
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background-image: radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
    background-size: 12px 12px;
    pointer-events: none;
}

.stat-card:hover { transform: translateY(-4px); }

.stat-card.new {
    background: var(--color-rose);
    box-shadow: 0 4px 20px rgba(244,63,94,0.3);
}
.stat-card.unpaid {
    background: var(--color-danger);
    box-shadow: 0 4px 20px rgba(220,38,38,0.3);
}
.stat-card.inprogress {
    background: var(--color-primary);
    box-shadow: 0 4px 20px rgba(37,99,235,0.3);
}
.stat-card.subcontractor {
    background: var(--color-amber);
    box-shadow: 0 4px 20px rgba(245,158,11,0.3);
}
.stat-card.completed {
    background: var(--color-success);
    box-shadow: 0 4px 20px rgba(5,150,105,0.3);
}

.stat-card h5 {
    font-family: var(--font-display);
    font-size: 0.8125rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    position: relative;
    z-index: 1;
}

.stat-card h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
}

.stat-card-link {
    text-decoration: none;
    display: block;
    cursor: pointer;
}

.stat-card-link:hover .stat-card { transform: translateY(-5px); }
.stat-card-link:hover .stat-card.new       { box-shadow: 0 8px 30px rgba(244,63,94,0.4); }
.stat-card-link:hover .stat-card.unpaid     { box-shadow: 0 8px 30px rgba(220,38,38,0.4); }
.stat-card-link:hover .stat-card.inprogress { box-shadow: 0 8px 30px rgba(37,99,235,0.4); }
.stat-card-link:hover .stat-card.subcontractor { box-shadow: 0 8px 30px rgba(245,158,11,0.4); }
.stat-card-link:hover .stat-card.completed  { box-shadow: 0 8px 30px rgba(5,150,105,0.4); }

.stat-card-link .stat-card h5,
.stat-card-link .stat-card h2 {
    color: white;
}

/* === Form controls === */

.form-control, .form-select {
    font-family: var(--font-body);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
    color: var(--color-text);
    font-size: 0.875rem;
}

.form-control::placeholder {
    color: var(--color-text-tertiary);
}

/* === Validation === */

.valid.modified:not([type=checkbox]) {
    outline: 1.5px solid var(--color-success);
}

.invalid {
    outline: 1.5px solid var(--color-danger);
}

.validation-message {
    color: var(--color-danger);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

.blazor-error-boundary {
    background: var(--color-danger);
    padding: 1rem 1rem 1rem 1.5rem;
    color: white;
    font-family: var(--font-display);
    border-radius: var(--radius-sm);
}

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

.darker-border-checkbox.form-check-input {
    border-color: #94a3b8;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--color-text-tertiary);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* === List group === */

.list-group-item {
    border-radius: var(--radius-sm) !important;
    margin-bottom: 0.5rem;
    border: 1px solid var(--color-border);
    transition: border-color var(--duration-fast) var(--ease-out);
}

.list-group-item:hover {
    border-color: var(--color-primary);
}

/* === Spinner === */

.spinner-border {
    color: var(--color-primary);
}

/* === Progress bar === */

.progress-bar {
    background-color: var(--color-primary);
}

/* === Alerts === */

.alert {
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.alert-info {
    background: var(--color-primary-soft);
    border: 1px solid rgba(37,99,235,0.15);
    border-left: 4px solid var(--color-primary);
    color: var(--color-primary-hover);
}

.alert-success {
    background: var(--color-success-soft);
    border: 1px solid rgba(5,150,105,0.15);
    border-left: 4px solid var(--color-success);
    color: #047857;
}

.alert-danger {
    background: var(--color-danger-soft);
    border: 1px solid rgba(220,38,38,0.15);
    border-left: 4px solid var(--color-danger);
    color: #b91c1c;
}

.alert-warning {
    background: var(--color-warning-soft);
    border: 1px solid rgba(217,119,6,0.15);
    border-left: 4px solid var(--color-warning);
    color: #92400e;
}

/* === Pagination === */

.pagination {
    margin-bottom: 0;
    gap: 4px;
}

.pagination .page-link {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    transition: all var(--duration-fast) var(--ease-out);
    font-size: 0.8125rem;
}

.pagination .page-link:hover:not(.disabled) {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-colored) var(--color-primary-glow);
}

.pagination .page-item.active .page-link {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-colored) var(--color-primary-glow);
}

.pagination .page-item.disabled .page-link {
    color: var(--color-text-tertiary);
    background-color: var(--color-surface);
    border-color: var(--color-border);
    cursor: not-allowed;
}

/* === Custom scrollbar === */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-text-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-secondary); }

/* === Selection === */

::selection {
    background: var(--color-primary);
    color: white;
}

/* === Page entrance animation === */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.content > * {
    animation: fadeInUp 0.3s var(--ease-out) both;
}

.stat-card-link:nth-child(1) { animation: fadeInUp 0.3s var(--ease-out) 0.05s both; }
.stat-card-link:nth-child(2) { animation: fadeInUp 0.3s var(--ease-out) 0.10s both; }
.stat-card-link:nth-child(3) { animation: fadeInUp 0.3s var(--ease-out) 0.15s both; }
.stat-card-link:nth-child(4) { animation: fadeInUp 0.3s var(--ease-out) 0.20s both; }
.stat-card-link:nth-child(5) { animation: fadeInUp 0.3s var(--ease-out) 0.25s both; }

/* === Accessibility: reduced motion === */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
