/* KGI Pricing Tool - Styles */

:root {
    --kg-red: #C02026;
    --kg-red-dark: #9a1a1f;
    --kg-link: #0563C1;
    --border-color: #ddd;
    --bg-light: #f5f5f5;
    --bg-white: #ffffff;
    --text-primary: #333;
    --text-secondary: #666;
    --warning-bg: #fff3cd;
    --warning-border: #ffc107;
    --success-bg: #d4edda;
    --success-border: #28a745;
    --error-bg: #f8d7da;
    --error-border: #dc3545;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Aptos Narrow', 'Arial Narrow', Calibri, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-light);
}

/* Header */
.header {
    background: var(--kg-red);
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
}

/* Breadcrumb strip inside the header h1 (shared across all pages) */
.header h1 a { color: white; text-decoration: none; }
.header h1 a:hover { text-decoration: underline; }
.header h1 .crumb-current { font-weight: 300; opacity: 0.85; }

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right .user-name {
    font-size: 13px;
    opacity: 0.9;
}

.header-right a,
.header-right button {
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-family: inherit;
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.header-right a:hover,
.header-right button:hover {
    background: rgba(255,255,255,0.15);
}

/* Main content */
.container {
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Cards */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--kg-red);
}

/* Search inputs */
.search-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.search-group input:focus {
    outline: none;
    border-color: var(--kg-red);
}

.search-group button {
    padding: 8px 16px;
    background: var(--kg-red);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
}

.search-group button:hover {
    background: var(--kg-red-dark);
}

/* Autocomplete dropdown */
.autocomplete-wrapper {
    position: relative;
    flex: 1;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.autocomplete-list.visible {
    display: block;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f0f0f0;
}

.autocomplete-item .item-main {
    font-weight: 600;
}

.autocomplete-item .item-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Customer card */
.customer-card {
    display: none;
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 12px 16px;
    margin-top: 12px;
}

.customer-card.visible {
    display: block;
}

.customer-card .customer-name {
    font-size: 16px;
    font-weight: 600;
}

.customer-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.customer-detail-item {
    font-size: 13px;
}

.customer-detail-item .label {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
}

/* Warning badges */
.warning-badge {
    display: inline-block;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: #856404;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin: 2px 0;
}

.exception-badge {
    display: inline-block;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.exception-badge.expired {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #6c757d;
    text-decoration: line-through;
}

/* Pricing table */
.pricing-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    table-layout: fixed;
}

.pricing-table th {
    background: var(--kg-red);
    color: white;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pricing-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Description column wraps */
.pricing-table th.col-desc,
.pricing-table td.col-desc {
    white-space: normal;
    overflow: visible;
}

.pricing-table tr:hover {
    background: #f8f9fa;
}

.pricing-table .text-right {
    text-align: right;
}

.pricing-table .text-center {
    text-align: center;
}

.pricing-table input.qty-input {
    width: 60px;
    text-align: center;
    padding: 4px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
}

/* Waterfall detail panel */
.waterfall-panel {
    display: none;
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
    margin: 8px 0;
}

.waterfall-panel.visible {
    display: block;
}

.waterfall-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

.waterfall-row .label {
    color: var(--text-secondary);
}

.waterfall-row .value {
    font-weight: 600;
    text-align: right;
}

.waterfall-row.highlight {
    background: #fff3cd;
    padding: 4px 8px;
    margin: 0 -8px;
    border-radius: 4px;
}

.waterfall-row.total {
    border-top: 2px solid var(--text-primary);
    border-bottom: none;
    font-size: 15px;
    padding-top: 8px;
}

/* Cost source banners */
.cost-banner {
    border-radius: 4px;
    padding: 8px 14px;
    margin: 8px 0;
    font-size: 13px;
    font-weight: 600;
}

.cost-banner-historical {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.cost-banner-none {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
}

/* Floor / previous price warning */
.floor-warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: 4px;
    padding: 10px 14px;
    margin: 8px 0;
    font-size: 13px;
    color: #856404;
}

.prev-price-warning {
    background: #fff8e1;
    color: #856404;
}

/* Currency toggle */
.currency-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.currency-toggle select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
}

.rate-display {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Action buttons */
.actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
}

.btn-primary {
    background: var(--kg-red);
    color: white;
}

.btn-primary:hover {
    background: var(--kg-red-dark);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-outline-primary {
    background: var(--bg-white);
    color: var(--kg-red);
    border: 1px solid var(--kg-red);
}

.btn-outline-primary:hover {
    background: #fdf0f0;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--kg-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

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

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    z-index: 999;
    justify-content: center;
    align-items: center;
}

.loading-overlay.visible {
    display: flex;
}

/* Expand/collapse toggle */
.toggle-waterfall {
    background: none;
    border: none;
    color: var(--kg-link);
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
    font-family: inherit;
}

/* Exception dropdown filters */
.exc-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 12px;
}

.exc-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.exc-filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.exc-filter-group select {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    min-width: 120px;
}

/* Active (non-blank) filter: bold text + KG-red left bar */
.exc-filter-group select.filter-active {
    font-weight: 600;
    border-left: 4px solid #C02026;
    padding-left: 8px;
}

/* Home page tile grid */
.tile-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.tile {
    display: flex;
    text-decoration: none;
    color: inherit;
}

.tile .tile-card {
    text-align: center;
    padding: 40px 24px;
    width: 280px;
    transition: box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
}

.tile .tile-card:hover {
    border-color: var(--kg-red);
    box-shadow: 0 2px 12px rgba(192, 32, 38, 0.15);
}

.tile-icon {
    margin-bottom: 16px;
}

.tile-icon svg {
    width: 48px;
    height: 48px;
    color: var(--kg-red);
}

.tile-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}

.tile-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    .customer-details {
        grid-template-columns: 1fr 1fr;
    }
}
