/* KATTO's ERP — Windows Vista Aero */

:root {
    --vista-deep: #041e3a;
    --vista-blue: #1b6ca8;
    --vista-sky: #3a9ad9;
    --vista-light: #7ec8f0;
    --vista-green: #2d8f4e;
    --vista-green-light: #5cb85c;
    --vista-teal: #1a8a7a;
    --glass-white: rgba(255, 255, 255, 0.82);
    --glass-border: rgba(255, 255, 255, 0.9);
    --glass-shadow: rgba(0, 20, 50, 0.45);
    --titlebar-top: #5eb0f0;
    --titlebar-mid: #3a8fd9;
    --titlebar-bottom: #1a5a94;
    --text: #0f2430;
    --text-muted: #3d5a6e;
    --accent: #0078d7;
    --danger: #c42b1c;
    --success: #107c10;
    --radius: 10px;
    --font: 'Segoe UI', 'Segoe UI Variable', Tahoma, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    background: var(--vista-deep);
}

/* Aurora canvas + CSS wave layers */
#auroraCanvas,
.aurora-canvas {
    position: fixed;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    display: block;
}

.vista-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.35;
}

.vista-wave {
    position: absolute;
    width: 200%;
    height: 60%;
    left: -50%;
    border-radius: 45%;
    opacity: 0.55;
    filter: blur(1px);
}

.vista-wave-1 {
    bottom: -15%;
    background: linear-gradient(90deg, transparent, rgba(62, 168, 230, 0.7), rgba(45, 143, 78, 0.5), transparent);
    animation: wave-drift 18s ease-in-out infinite;
}

.vista-wave-2 {
    bottom: 5%;
    background: linear-gradient(90deg, transparent, rgba(30, 120, 200, 0.6), rgba(26, 138, 122, 0.45), transparent);
    animation: wave-drift 22s ease-in-out infinite reverse;
    opacity: 0.45;
}

.vista-wave-3 {
    bottom: 25%;
    height: 40%;
    background: linear-gradient(90deg, transparent, rgba(126, 200, 240, 0.35), rgba(92, 184, 92, 0.3), transparent);
    animation: wave-drift 26s ease-in-out infinite;
    opacity: 0.35;
}

.vista-wave-4 {
    top: 10%;
    height: 35%;
    background: radial-gradient(ellipse at center, rgba(58, 159, 217, 0.4) 0%, transparent 70%);
    animation: wave-pulse 12s ease-in-out infinite;
}

.vista-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 70% 20%, rgba(126, 200, 240, 0.25) 0%, transparent 50%),
                radial-gradient(ellipse at 20% 80%, rgba(45, 143, 78, 0.2) 0%, transparent 45%);
    pointer-events: none;
}

@keyframes wave-drift {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    50% { transform: translateX(8%) rotate(2deg); }
}

@keyframes wave-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

/* Vista window chrome */
.vista-window {
    background: var(--glass-white);
    backdrop-filter: blur(12px) saturate(130%);
    -webkit-backdrop-filter: blur(12px) saturate(130%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 24px var(--glass-shadow), inset 0 1px 0 rgba(255,255,255,0.9);
    overflow: hidden;
    margin-bottom: 20px;
}

.window-titlebar {
    background: linear-gradient(180deg, var(--titlebar-top) 0%, var(--titlebar-mid) 50%, var(--titlebar-bottom) 100%);
    color: #fff;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
    border-bottom: 1px solid rgba(0,0,0,0.2);
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.window-body { padding: 18px 20px; }

/* Header */
.vista-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(180deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.35) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 2px 12px rgba(0,40,80,0.2);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    flex-shrink: 0;
}

.logo-gem,
.katto-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, #5eb0f0 0%, #2d8f4e 55%, #1a6ebc 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.55), 0 3px 10px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.logo-text { display: flex; flex-direction: column; line-height: 1.25; }
.logo-text strong { font-size: 15px; letter-spacing: 0.02em; }

.user-chip {
    font-size: 12px;
    padding: 4px 10px;
    background: rgba(255,255,255,0.45);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 4px;
    color: var(--text-muted);
}

.nav-manage {
    color: var(--accent) !important;
    font-weight: 600 !important;
}

.main-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }

.main-nav a {
    text-decoration: none;
    color: var(--text);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.main-nav a:hover {
    background: rgba(255,255,255,0.5);
    border-color: rgba(255,255,255,0.7);
}

.main-nav a.active {
    background: linear-gradient(180deg, #fff 0%, #e8f4fc 100%);
    border-color: #9cc9e8;
    box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(0,0,0,0.08);
}

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.lang-switch {
    display: flex;
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 4px;
    overflow: hidden;
    background: rgba(255,255,255,0.3);
}

.lang-switch a {
    padding: 5px 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.lang-switch a.active,
.lang-switch a:hover { background: rgba(255,255,255,0.65); }

/* Buttons — Vista style */
.btn-vista {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    border: 1px solid #8ebcd4;
    border-radius: 4px;
    background: linear-gradient(180deg, #fefefe 0%, #e8f0f6 45%, #d0e4f2 100%);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(0,0,0,0.12);
    transition: all 0.12s;
}

.btn-vista:hover {
    background: linear-gradient(180deg, #fff 0%, #eef6fc 45%, #d8eaf8 100%);
    border-color: #6aa8cc;
}

.btn-vista:active {
    background: linear-gradient(180deg, #d0e4f2 0%, #e0ecf4 100%);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

.btn-vista.btn-sm { padding: 4px 12px; font-size: 12px; }

.btn-vista.btn-primary {
    background: linear-gradient(180deg, #6ec2f0 0%, #3a9ad9 45%, #1e6cb0 100%);
    border-color: #1a5a94;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.25);
}

.btn-vista.btn-primary:hover {
    background: linear-gradient(180deg, #7ecaf2 0%, #4aa8e0 45%, #2578bc 100%);
}

.btn-vista.btn-danger {
    background: linear-gradient(180deg, #f08070 0%, #d04030 45%, #a82018 100%);
    border-color: #8a1a12;
    color: #fff;
}

.btn-vista.btn-ghost {
    background: transparent;
    border-color: rgba(255,255,255,0.5);
}

/* Main */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.page-hero h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.page-hero p { color: var(--text-muted); line-height: 1.5; }

.section { margin-bottom: 24px; }
.section-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-link { text-decoration: none; color: inherit; transition: transform 0.15s; }
.stat-link:hover { transform: translateY(-2px); }

.stat-body { text-align: center; padding: 20px !important; }

/* Chart */
.chart-window .chart-container { min-height: 340px; position: relative; }
.chart-window canvas { max-height: 320px; }

/* Tables */
.table-body { padding: 0 !important; }
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 10px 14px;
    text-align: start;
    border-bottom: 1px solid rgba(0,60,100,0.08);
}

.data-table th {
    background: linear-gradient(180deg, #f0f6fb 0%, #e2edf5 100%);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    white-space: nowrap;
}

.data-table tbody tr:hover { background: rgba(58, 154, 217, 0.06); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid rgba(0,0,0,0.1);
    white-space: nowrap;
}

.badge-pending { background: #fff3cd; color: #856404; }
.badge-in_transit { background: #cce5ff; color: #004085; }
.badge-delivered { background: #d4edda; color: #155724; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-open { background: #cce5ff; color: #004085; }
.badge-closed { background: #e2e3e5; color: #383d41; }
.badge-in_progress { background: #d1ecf1; color: #0c5460; }
.badge-high, .badge-urgent { background: #f8d7da; color: #721c24; }
.badge-medium { background: #fff3cd; color: #856404; }
.badge-low { background: #d4edda; color: #155724; }

.stars { color: #e8a317; letter-spacing: 1px; font-size: 14px; }

/* Reviews */
.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.review-card .company { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.review-card .rating-row { margin-bottom: 8px; }
.review-card .comment { line-height: 1.5; font-size: 13px; }
.review-card .review-date { font-size: 11px; color: var(--text-muted); margin-top: 10px; }

.review-form { max-width: 640px; }

/* Forms */
.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #a8c8dc;
    border-radius: 3px;
    background: #fff;
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0,120,215,0.2), inset 0 1px 2px rgba(0,0,0,0.06);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

.form-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* Login screen */
.login-screen {
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: radial-gradient(ellipse at center, transparent 20%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
}

.login-stage {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 24px;
    margin: auto;
}

.login-window.vista-window {
    width: 100%;
    margin: 0;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.95);
    animation: login-rise 0.6s ease-out;
}

.login-titlebar { justify-content: space-between; }
.titlebar-icon {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8ed0ff, #3a9ad9);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.titlebar-controls { display: flex; gap: 5px; }
.titlebar-controls span {
    width: 11px; height: 11px;
    border-radius: 2px;
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(255,255,255,0.15);
}

.login-body { padding: 28px 26px 24px !important; }

.login-brand { text-align: center; margin-bottom: 22px; }

.katto-logo {
    width: 72px; height: 72px;
    margin: 0 auto 14px;
    border-radius: 16px;
    background: linear-gradient(145deg, #6ec2f0 0%, #3a9ad9 40%, #2d8f4e 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 800; color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.25);
    box-shadow: 0 8px 24px rgba(0,80,160,0.4), inset 0 2px 0 rgba(255,255,255,0.45);
    transition: transform 0.3s, box-shadow 0.3s;
}

.katto-logo.glow {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0,120,200,0.55), inset 0 2px 0 rgba(255,255,255,0.55);
}

.login-brand h1 { font-size: 22px; margin-bottom: 6px; }
.login-sub { color: var(--text-muted); font-size: 13px; }

.login-alert {
    background: #fde8e8;
    border: 1px solid #f5b0b0;
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.btn-login { width: 100%; padding: 10px; font-size: 14px; margin-top: 4px; }
.btn-spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

.login-lang { margin-top: 18px; justify-content: center; display: flex; }

.login-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 10px;
    flex-wrap: wrap;
}

.login-lang-inline { display: flex; }

.form-group input.invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(196,43,28,0.2);
}

@keyframes login-rise {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.shake { animation: shake 0.45s ease-in-out; }

.fade-in {
    animation: fade-in 0.45s ease-out both;
}

.row-in {
    animation: fade-in 0.35s ease-out both;
}

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

.page-hero-body h1 { font-size: 20px; font-weight: 600; }

.stat-value {
    font-size: 42px;
    font-weight: 200;
    background: linear-gradient(180deg, var(--accent), var(--vista-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Admin */
.admin-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.admin-form .window-body { padding-top: 14px; }
.admin-form h3 { display: none; }

.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.action-btns form { display: inline; }

/* Flash */
.flash { margin-bottom: 16px; }
.flash-success .window-body { border-left: 3px solid var(--success); }
.flash-error .window-body { border-left: 3px solid var(--danger); }
.flash-info .window-body { border-left: 3px solid var(--accent); }

.no-data {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Footer */
.vista-footer {
    text-align: center;
    padding: 16px;
    background: rgba(0,0,0,0.15);
    color: rgba(255,255,255,0.75);
    font-size: 12px;
}

.vista-footer .version { font-size: 11px; margin-top: 2px; opacity: 0.7; }

/* RTL */
[dir="rtl"] .data-table th,
[dir="rtl"] .data-table td { text-align: right; }

/* Responsive */
@media (max-width: 768px) {
    .header-inner { flex-direction: column; align-items: stretch; }
    .main-nav { justify-content: center; }
    .header-actions { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .vista-wave, .vista-wave-4, .fade-in, .row-in, .login-window { animation: none; }
    html { scroll-behavior: auto; }
    #auroraCanvas { display: none; }
}

/* Finance module */
.export-bar { margin-bottom: 16px; }
.export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.finance-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.finance-kpi .kpi-val {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    padding: 12px 8px;
}

.finance-table td:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }

.profit-pos { color: var(--success); }
.profit-neg { color: var(--danger); }

.finance-live-preview {
    margin: 12px 0;
    padding: 12px;
    background: rgba(255,255,255,0.35);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
}

.finance-live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.finance-live-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: rgba(255,255,255,0.5);
    border-radius: 4px;
    font-size: 12px;
}

.finance-live-item span { color: var(--text-muted); }
.finance-live-item strong { font-size: 14px; font-variant-numeric: tabular-nums; }

/* Analytics & search */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.chart-half .chart-container.chart-sm { height: 260px; }

.analytics-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.analytics-kpi .kpi-sub { font-size: 11px; color: var(--text-muted); padding: 0 12px 10px; }

.kpi-val { font-size: 22px; font-weight: 700; text-align: center; padding: 12px; }

.search-form { margin-bottom: 16px; }
.search-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.search-input { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--glass-border); border-radius: 4px; }

.search-list { list-style: none; padding: 0; margin: 0; }
.search-list li { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.2); }
.search-list a { color: var(--accent); text-decoration: none; }
.search-list a:hover { text-decoration: underline; }

.best-price-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.best-chip {
    padding: 10px 14px;
    background: rgba(255,255,255,0.45);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}
.chip-type { font-weight: 600; font-size: 13px; }
.chip-price { font-size: 18px; font-weight: 700; }
.chip-avg { font-size: 11px; color: var(--text-muted); }

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.quick-link-card { text-decoration: none; color: inherit; transition: transform 0.15s; }
.quick-link-card:hover { transform: translateY(-2px); }

.alert-window .window-body { border-left: 3px solid var(--danger); }
.alert-list { margin: 0 0 12px; padding-left: 18px; }
.alert-list li { margin-bottom: 6px; }

.badge-critical, .badge-high { background: rgba(220, 53, 69, 0.2); color: #a02030; }
.badge-medium { background: rgba(255, 193, 7, 0.25); color: #856404; }
.badge-low { background: rgba(40, 167, 69, 0.2); color: #1e7e34; }

.urgency-critical td { background: rgba(220, 53, 69, 0.08); }
.urgency-high td { background: rgba(255, 193, 7, 0.08); }

.ana-hint { margin-top: 12px; font-size: 12px; }

@media (max-width: 768px) {
    .charts-grid { grid-template-columns: 1fr; }
}
