/* ========================================
   KNU - Кошторисні Норми України
   Design System & Styles
   ======================================== */

:root {
    /* Color palette - deep blue/violet dark theme */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #38bdf8;
    
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    
    --border-subtle: rgba(148, 163, 184, 0.1);
    --border-active: rgba(59, 130, 246, 0.3);
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.1);
    
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Background Effects */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    pointer-events: none;
    z-index: 0;
}

.bg-glow--1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08), transparent 70%);
    top: -200px;
    right: -100px;
    animation: float1 20s ease-in-out infinite;
}

.bg-glow--2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.06), transparent 70%);
    bottom: -150px;
    left: -100px;
    animation: float2 25s ease-in-out infinite;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-30px, 30px) scale(1.1); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, -20px) scale(1.05); }
}

/* App Container */
.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: rgba(10, 14, 26, 0.85);
    border-bottom: 1px solid var(--border-subtle);
}

.header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--accent-primary);
}

.logo-text__main {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text__sub {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header__stats {
    display: flex;
    gap: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-item__value {
    font-weight: 700;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Hero / Search Section */
.hero {
    padding: 60px 24px 40px;
    text-align: center;
    transition: padding var(--transition-slow);
}

.hero.hero--compact {
    padding: 24px 24px 20px;
}

.hero__content {
    max-width: 720px;
    margin: 0 auto;
}

.hero__title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
    transition: all var(--transition-slow);
}

.hero--compact .hero__title {
    font-size: 0;
    margin: 0;
    opacity: 0;
    height: 0;
    overflow: hidden;
}

.hero__title-line {
    display: block;
    color: var(--text-primary);
}

.hero__title-accent {
    display: block;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero__subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-weight: 400;
    transition: all var(--transition-slow);
}

.hero--compact .hero__subtitle {
    font-size: 0;
    margin: 0;
    opacity: 0;
    height: 0;
    overflow: hidden;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 4px 8px;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.search-box:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.search-box__icon {
    padding: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--transition-fast);
}

.search-box:focus-within .search-box__icon {
    color: var(--accent-primary);
}

.search-box__input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: inherit;
    padding: 14px 8px;
    min-width: 0;
}

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

.search-box__clear {
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.search-box__clear:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.search-box__loader {
    padding: 12px;
    flex-shrink: 0;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
    animation: fadeIn 0.3s ease;
}

.filter-select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 32px 8px 12px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--transition-fast);
}

.filter-select:focus {
    border-color: var(--accent-primary);
}

.results-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Results Section */
.results {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px 60px;
    animation: fadeInUp 0.4s ease;
}

.results__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Result Card */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    cursor: pointer;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.result-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-active);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.result-card:hover::before {
    opacity: 1;
}

.result-card__header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 6px;
}

.result-card__code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: var(--accent-glow);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}

.result-card__name {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
}

.result-card__name mark {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border-radius: 2px;
    padding: 0 2px;
}

.result-card__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.result-card__unit {
    display: flex;
    align-items: center;
    gap: 4px;
}

.result-card__collection {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: var(--radius-sm);
    color: #a78bfa;
    font-weight: 500;
}

/* Load More */
.results__load-more {
    text-align: center;
    padding: 24px;
}

.btn {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    transition: all var(--transition-fast);
}

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

.btn--ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-active);
    color: var(--text-primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal__close {
    position: sticky;
    top: 16px;
    float: right;
    margin: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.modal__close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal__content {
    padding: 32px;
}

.modal__title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
    padding-right: 48px;
}

.modal__code {
    font-family: monospace;
    font-size: 1rem;
    color: var(--accent-primary);
    font-weight: 600;
    margin-bottom: 12px;
}

.modal__info {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.modal__info-item {
    font-size: 0.85rem;
    padding: 4px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.modal__info-item span {
    color: var(--text-primary);
    font-weight: 600;
}

/* Resources Table */
.resource-section {
    margin-bottom: 24px;
}

.resource-section__title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.resource-section__title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.resource-section--labor .resource-section__title { color: #60a5fa; }
.resource-section--machines .resource-section__title { color: #f59e0b; }
.resource-section--materials .resource-section__title { color: #10b981; }

.resource-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.resource-table th {
    text-align: left;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.resource-table td {
    padding: 8px 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.05);
}

.resource-table tr:hover td {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.resource-table .code-cell {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.resource-table .qty-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-primary);
}

/* Footer */
.footer {
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
    padding: 24px;
    text-align: center;
}

.footer__inner {
    max-width: 1200px;
    margin: 0 auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer__source {
    margin-top: 4px;
    font-size: 0.75rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state__icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state__text {
    font-size: 1rem;
    margin-bottom: 8px;
}

.empty-state__hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive */
@media (max-width: 640px) {
    .hero__title {
        font-size: 2rem;
    }
    
    .hero__subtitle {
        font-size: 0.95rem;
    }
    
    .search-box__input {
        font-size: 1rem;
    }
    
    .result-card__header {
        flex-direction: column;
        gap: 6px;
    }
    
    .result-card__meta {
        flex-wrap: wrap;
    }
    
    .modal__content {
        padding: 20px;
    }
    
    .resource-table {
        font-size: 0.78rem;
    }
    
    .header__stats {
        display: none;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: rgba(59, 130, 246, 0.3);
}
