/* ============================================================
   BuildPrices — Black & Orange Theme
   ============================================================ */

:root {
    --bp-primary: #e8860c;
    --bp-primary-light: #f5a623;
    --bp-primary-dark: #c06e00;
    --bp-dark: #111111;
    --bp-dark-soft: #1a1a1a;
    --bp-dark-card: #222222;
    --bp-light: #f5f5f5;
    --bp-text: #333;
    --bp-text-muted: #777;
    --bp-green: #27ae60;
    --bp-red: #e74c3c;
    --bp-border: #e0e0e0;
    --bp-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --bp-shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --bp-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.12), 0 4px 6px -4px rgba(0,0,0,.1);
    --bp-radius: 12px;
    --bp-transition: .25s cubic-bezier(.4,0,.2,1);
}

body {
    background: var(--bp-light);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--bp-text);
    min-height: 100vh;
}
#materialsContainer { flex: 1; }

/* ---------- Navbar ---------- */

.navbar-bp {
    background: var(--bp-dark) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.navbar-bp .navbar-brand {
    font-weight: 700;
    letter-spacing: -.5px;
    font-size: 1.3rem;
    color: #fff !important;
}
.navbar-bp .navbar-brand i { color: var(--bp-primary); }
.navbar-bp .nav-link {
    color: rgba(255,255,255,.7) !important;
    transition: color var(--bp-transition);
}
.navbar-bp .nav-link:hover { color: var(--bp-primary) !important; }
.nav-key-info { color: rgba(255,255,255,.7); }

/* ---------- Hero ---------- */

.hero-section {
    background: linear-gradient(135deg, var(--bp-primary-dark) 0%, var(--bp-primary) 50%, var(--bp-primary-light) 100%);
    position: relative;
    overflow: hidden;
}
.hero-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}
.hero-section h1 { color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,.2); }
.hero-section .lead { color: rgba(255,255,255,.9) !important; }

/* ---------- Animations ---------- */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes growWidth {
    from { width: 0; }
    to   { width: 100%; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

.animate-fade-in { animation: fadeInUp .5s ease-out both; }
.animate-fade { animation: fadeIn .4s ease-out both; }
.animate-slide { animation: slideInLeft .4s ease-out both; }

/* Stagger children */
.stagger-children > * { animation: fadeInUp .4s ease-out both; }
.stagger-children > *:nth-child(1)  { animation-delay: .04s; }
.stagger-children > *:nth-child(2)  { animation-delay: .08s; }
.stagger-children > *:nth-child(3)  { animation-delay: .12s; }
.stagger-children > *:nth-child(4)  { animation-delay: .16s; }
.stagger-children > *:nth-child(5)  { animation-delay: .20s; }
.stagger-children > *:nth-child(6)  { animation-delay: .24s; }
.stagger-children > *:nth-child(7)  { animation-delay: .28s; }
.stagger-children > *:nth-child(8)  { animation-delay: .32s; }
.stagger-children > *:nth-child(9)  { animation-delay: .36s; }
.stagger-children > *:nth-child(10) { animation-delay: .40s; }
.stagger-children > *:nth-child(11) { animation-delay: .44s; }
.stagger-children > *:nth-child(12) { animation-delay: .48s; }
.stagger-children > *:nth-child(13) { animation-delay: .52s; }

/* Scroll reveal */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .5s ease, transform .5s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ---------- Cards ---------- */

.card {
    border: 1px solid var(--bp-border);
    border-radius: var(--bp-radius);
    transition: transform var(--bp-transition), box-shadow var(--bp-transition);
}

.material-card {
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background: #fff;
}
.material-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--cat-color, var(--bp-primary));
    border-radius: 4px 0 0 4px;
    transition: width var(--bp-transition);
}
.material-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--bp-shadow-lg);
}
.material-card:hover::before { width: 6px; }
.material-card .card-body { padding: 1rem 1rem 1rem 1.25rem; }
.material-card .material-name {
    font-weight: 600;
    font-size: .95rem;
    color: var(--bp-dark);
    margin-bottom: .25rem;
}
.material-card .material-unit { font-size: .78rem; color: var(--bp-text-muted); }
.material-card .material-link {
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--bp-primary);
    transition: color var(--bp-transition);
}
.material-card .material-link:hover { color: var(--bp-primary-dark); }
.material-card .material-link i { transition: transform var(--bp-transition); }
.material-card:hover .material-link i { transform: translateX(3px); }

/* ---------- API Key Card ---------- */

.api-key-card {
    background: var(--bp-dark);
    border: none;
    border-radius: var(--bp-radius);
    overflow: hidden;
    color: #fff;
}
.api-key-card .card-body { padding: 1.25rem 1.5rem; }

.key-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 8px;
    padding: .35rem .75rem;
    font-family: 'Courier New', monospace;
    font-size: .82rem;
    color: var(--bp-primary-light);
    word-break: break-all;
    max-width: 100%;
}

.key-stat-text {
    color: rgba(255,255,255,.7);
}

.key-progress {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,.15);
    overflow: hidden;
}
.key-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--bp-primary), var(--bp-primary-light));
    transition: width .6s ease-out;
}

.btn-copy-key {
    background: none;
    border: 1px solid rgba(255,255,255,.2);
    color: rgba(255,255,255,.7);
    border-radius: 6px;
    padding: .25rem .5rem;
    font-size: .78rem;
    cursor: pointer;
    transition: all var(--bp-transition);
}
.btn-copy-key:hover { border-color: var(--bp-primary); color: var(--bp-primary); }

.btn-logout {
    background: none;
    border: 1px solid rgba(255,255,255,.2);
    color: rgba(255,255,255,.5);
    border-radius: 8px;
    padding: .35rem .75rem;
    font-size: .8rem;
    cursor: pointer;
    transition: all var(--bp-transition);
}
.btn-logout:hover { border-color: var(--bp-red); color: var(--bp-red); }

/* ---------- Category Sections ---------- */

.category-section { margin-bottom: 2rem; }
.category-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .25rem;
}
.category-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bp-dark);
    margin: 0;
}
.category-header .cat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}
.category-desc {
    color: var(--bp-text-muted);
    font-size: .9rem;
    margin-bottom: .75rem;
    padding-left: calc(36px + .75rem);
}

/* ---------- Material Page ---------- */

.breadcrumb-bp {
    background: transparent;
    padding: .75rem 0;
    margin-bottom: 0;
}
.breadcrumb-bp a {
    color: var(--bp-primary);
    text-decoration: none;
}
.breadcrumb-bp a:hover { text-decoration: underline; }

.material-header {
    text-align: center;
    padding: 2rem 0 1.5rem;
}
.material-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--bp-dark);
}

.location-card {
    background: #fff;
    border-radius: var(--bp-radius);
    border: 2px solid var(--bp-border);
    padding: 1.5rem;
    transition: border-color var(--bp-transition);
}
.location-card:focus-within { border-color: var(--bp-primary); }

/* ---------- Price Range Display ---------- */

.price-result {
    background: #fff;
    border-radius: var(--bp-radius);
    border: 1px solid var(--bp-border);
    padding: 2rem;
    box-shadow: var(--bp-shadow);
}

.price-values {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1rem;
}
.price-values .price-item { text-align: center; flex: 1; }
.price-values .price-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .25rem;
}
.price-values .price-value { font-weight: 800; line-height: 1; }
.price-low .price-label { color: var(--bp-green); }
.price-low .price-value { color: var(--bp-green); font-size: 1.5rem; }
.price-avg .price-label { color: var(--bp-primary); }
.price-avg .price-value { color: var(--bp-primary); font-size: 2.2rem; }
.price-high .price-label { color: var(--bp-red); }
.price-high .price-value { color: var(--bp-red); font-size: 1.5rem; }

.price-bar {
    position: relative;
    height: 14px;
    border-radius: 7px;
    background: #e0e0e0;
    overflow: hidden;
    margin-bottom: 1rem;
}
.price-bar-fill {
    height: 100%;
    border-radius: 7px;
    background: linear-gradient(90deg, var(--bp-green) 0%, #a3d977 25%, var(--bp-primary-light) 50%, var(--bp-primary) 75%, var(--bp-red) 100%);
    animation: growWidth .8s ease-out both;
    animation-delay: .3s;
}
.price-bar-marker {
    position: absolute;
    top: -8px;
    transform: translateX(-50%);
    transition: left .6s ease-out;
}
.price-bar-marker::after {
    content: '';
    display: block;
    width: 12px;
    height: 30px;
    background: var(--bp-dark);
    border-radius: 6px;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,.3);
}

.price-meta {
    background: #fff8ee;
    border: 1px solid #fde0a8;
    border-radius: 8px;
    padding: .75rem 1rem;
    font-size: .85rem;
    color: #8a5a00;
}

.price-comment {
    background: #f9f9f9;
    border-radius: 8px;
    padding: .75rem 1rem;
    font-size: .88rem;
    color: #555;
    border-left: 3px solid var(--bp-primary);
}

/* ---------- History Table ---------- */

.history-section {
    background: #fff;
    border-radius: var(--bp-radius);
    border: 1px solid var(--bp-border);
    overflow: hidden;
}
.history-section .table { margin-bottom: 0; font-size: .88rem; }
.history-section .table th {
    background: var(--bp-dark);
    color: var(--bp-primary-light);
    border-bottom: none;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.history-section .table td {
    vertical-align: middle;
    color: var(--bp-text);
}

/* ---------- Badges ---------- */

.badge-updated {
    background: rgba(255,255,255,.2);
    color: #fff;
    font-weight: 500;
    padding: .4rem .8rem;
    border-radius: 20px;
    font-size: .82rem;
    backdrop-filter: blur(4px);
}
.badge-unit {
    background: #f0f0f0;
    color: #555;
    font-weight: 500;
    padding: .25rem .6rem;
    border-radius: 6px;
    font-size: .78rem;
}

/* ---------- Buttons ---------- */

.btn-bp {
    background: linear-gradient(135deg, var(--bp-primary), var(--bp-primary-light));
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: .6rem 1.5rem;
    font-weight: 600;
    transition: all var(--bp-transition);
    box-shadow: 0 2px 8px rgba(232,134,12,.35);
}
.btn-bp:hover {
    background: linear-gradient(135deg, var(--bp-primary-dark), var(--bp-primary));
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232,134,12,.45);
}
.btn-bp:active { transform: translateY(0); }

.btn-outline-bp {
    border: 2px solid var(--bp-primary);
    color: var(--bp-primary);
    background: transparent;
    border-radius: 10px;
    padding: .5rem 1.25rem;
    font-weight: 600;
    transition: all var(--bp-transition);
}
.btn-outline-bp:hover {
    background: var(--bp-primary);
    color: #fff;
}

/* ---------- Skeleton Loading ---------- */

.skeleton {
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: pulse 1.5s ease-in-out infinite;
    border-radius: 6px;
}

/* ---------- Error/Empty States ---------- */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state p { font-size: 1.05rem; }

.error-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--bp-radius);
    padding: 1rem 1.25rem;
    color: #991b1b;
    display: flex;
    align-items: center;
    gap: .75rem;
}
.error-banner i { font-size: 1.25rem; flex-shrink: 0; }

/* ---------- Footer ---------- */

.footer-bp {
    background: var(--bp-dark);
    color: #777;
    font-size: .85rem;
}
.footer-bp a { color: var(--bp-primary-light); text-decoration: none; }
.footer-bp a:hover { color: var(--bp-primary); }

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .hero-section .container { padding-top: 2rem !important; padding-bottom: 2rem !important; }
    .hero-section h1 { font-size: 1.75rem; }
    .material-header h1 { font-size: 1.5rem; }
    .price-values .price-avg .price-value { font-size: 1.75rem; }
    .price-values .price-low .price-value,
    .price-values .price-high .price-value { font-size: 1.25rem; }
    .category-desc { padding-left: 0; }
    .key-badge { font-size: .72rem; }
}

/* ---------- Misc ---------- */

.spinner-bp {
    width: 2rem;
    height: 2rem;
    border: 3px solid #e0e0e0;
    border-top-color: var(--bp-primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Calculator ---------- */

.calc-container {
    background: #fff;
    border-radius: var(--bp-radius);
    border: 2px solid var(--bp-primary);
    box-shadow: var(--bp-shadow-md);
    overflow: hidden;
}

.calc-header {
    background: var(--bp-dark);
    color: #fff;
    padding: .85rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.calc-header h5 {
    font-size: 1rem;
    font-weight: 700;
}
.calc-header h5 i { color: var(--bp-primary); margin-right: .4rem; }

.calc-close-btn {
    color: rgba(255,255,255,.6);
    border: none;
    padding: .25rem .5rem;
    line-height: 1;
    transition: color var(--bp-transition);
}
.calc-close-btn:hover { color: #fff; }

.calc-body {
    padding: 1.25rem;
}

.calc-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--bp-text);
    margin-bottom: .25rem;
}
.calc-unit { color: var(--bp-text-muted); font-weight: 400; }

.calc-field-heading {
    font-size: .85rem;
    font-weight: 700;
    color: var(--bp-primary-dark);
    border-bottom: 1px solid var(--bp-border);
    padding-bottom: .4rem;
}

.calc-result {
    border-top: 1px solid var(--bp-border);
}
.calc-result-inner {
    padding: 1.25rem;
}

.calc-result-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--bp-dark);
    margin-bottom: .75rem;
}
.calc-result-title i { color: var(--bp-primary); }

.calc-breakdown {
    width: 100%;
    font-size: .85rem;
    margin-bottom: 1rem;
}
.calc-breakdown td {
    padding: .3rem .5rem;
    border-bottom: 1px solid #f0f0f0;
}
.calc-breakdown-bold td {
    font-weight: 700;
    color: var(--bp-dark);
    border-bottom: 2px solid var(--bp-primary);
}

.calc-total {
    background: var(--bp-dark);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: .75rem;
}
.calc-cost-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}
.calc-cost-label {
    color: rgba(255,255,255,.7);
    font-size: .85rem;
    font-weight: 600;
}
.calc-cost-values { text-align: right; }
.calc-cost-range {
    color: var(--bp-primary-light);
    font-size: 1.15rem;
    font-weight: 800;
}
.calc-cost-avg {
    display: block;
    color: rgba(255,255,255,.5);
    font-size: .78rem;
}
.calc-cost-detail {
    color: rgba(255,255,255,.4);
    font-size: .78rem;
    margin-top: .35rem;
}

.calc-extra-row {
    display: flex;
    justify-content: space-between;
    color: rgba(255,255,255,.6);
    font-size: .82rem;
    padding-top: .5rem;
    margin-top: .5rem;
    border-top: 1px solid rgba(255,255,255,.1);
}

.calc-grand-total {
    background: #fffcf5;
    border: 2px solid var(--bp-primary);
    border-radius: 8px;
    padding: .85rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}
.calc-grand-total > span:first-child {
    font-size: .85rem;
    font-weight: 600;
    color: var(--bp-text);
}
.calc-grand-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--bp-primary-dark);
}

.calc-actions {
    display: flex;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--bp-border);
    background: #fafafa;
}

.calc-validation-error {
    padding: 1rem 1.25rem;
    color: #991b1b;
    background: #fef2f2;
    border-radius: 6px;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.calc-validation-error i { font-size: 1.1rem; }

@media (max-width: 768px) {
    .calc-actions { flex-direction: column; }
    .calc-actions .btn { width: 100%; }
    .calc-cost-row { flex-direction: column; text-align: center; }
    .calc-cost-values { text-align: center; }
    .calc-grand-total { flex-direction: column; text-align: center; }
}

.form-control:focus, .form-select:focus {
    border-color: var(--bp-primary);
    box-shadow: 0 0 0 .2rem rgba(232,134,12,.2);
}
