/* Heliora CRM - Glassmorphism Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Manrope:wght@400;500;600;700;800&display=swap');

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: #020617;
    color: #f8fafc;
    min-height: 100vh;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 { font-family: 'Manrope', sans-serif; }

a { color: #818cf8; text-decoration: none; }
a:hover { color: #a5b4fc; }

/* ===== WAVE BACKGROUND ===== */
.wave-bg {
    min-height: 100vh;
    background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #020617 60%);
    position: relative;
}

.wave-bg::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99,102,241,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(99,102,241,0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Cashflow green bg */
.cashflow-bg {
    background: linear-gradient(135deg, #0a1f1a 0%, #0d2818 50%, #0f172a 100%) !important;
}
.cashflow-bg::before {
    background:
        radial-gradient(ellipse at top right, rgba(16,185,129,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom left, rgba(6,78,59,0.1) 0%, transparent 50%);
}

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* Sidebar */
.sidebar {
    width: 256px;
    height: 100vh;
    position: fixed;
    left: 0; top: 0;
    background: rgba(2,6,23,0.8);
    backdrop-filter: blur(40px);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    z-index: 40;
    overflow-y: auto;
}

.sidebar-cashflow {
    background: linear-gradient(180deg, rgba(6,78,59,0.4) 0%, rgba(2,6,23,0.95) 100%);
    border-right-color: rgba(16,185,129,0.15);
}

.sidebar-logo {
    padding: 1.5rem;
    display: flex; align-items: center; justify-content: center;
    margin: 1rem 1rem 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255,255,255,0.05);
    background: rgba(255,255,255,0.05);
}
.sidebar-cashflow .sidebar-logo { background: rgba(16,185,129,0.1); }

.sidebar-logo img {
    height: 40px;
    filter: invert(1) brightness(200%);
}

/* Section Toggle */
.section-toggle {
    display: flex; gap: 0.5rem;
    padding: 0.25rem;
    margin: 0 1rem 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 0.5rem;
}
.section-toggle a {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    transition: all 0.2s;
}
.section-toggle a:hover { color: #f8fafc; }
.section-toggle a.active { background: rgba(255,255,255,0.1); color: #fff; }
.section-toggle a.active-cashflow { background: rgba(16,185,129,0.2); color: #34d399; }

/* Nav */
.sidebar nav { flex: 1; padding: 0 1rem; }

.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: #94a3b8;
    transition: all 0.2s;
    margin-bottom: 0.125rem;
    font-size: 0.9rem;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #f8fafc; }
.nav-item.active { background: rgba(99,102,241,0.2); color: #818cf8; }
.cashflow-bg .nav-item.active { background: rgba(16,185,129,0.2); color: #34d399; }

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-logout {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 256px;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* Mobile */
.mobile-header {
    display: none;
    position: fixed; top: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(15,23,42,0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    z-index: 50;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
}
.mobile-header img { height: 32px; filter: invert(1) brightness(200%); }

.mobile-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 39;
}
.mobile-overlay.show { display: block; }

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .mobile-header { display: flex; }
    .main-content { margin-left: 0; padding: 1rem; margin-top: 64px; }
}

/* ===== GLASS COMPONENTS ===== */
.glass-panel {
    background: rgba(15,23,42,0.4);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 1rem;
}

.glass-card {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 1rem;
    transition: all 0.3s;
}
.glass-card:hover { background: rgba(255,255,255,0.08); border-color: rgba(99,102,241,0.3); }

/* ===== METRIC CARDS ===== */
.metric-card {
    padding: 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
}
.metric-value {
    font-size: 1.75rem; font-weight: 700;
    font-family: 'Manrope', sans-serif;
}
.metric-label { font-size: 0.875rem; color: #94a3b8; margin-bottom: 0.25rem; }
.metric-icon {
    width: 48px; height: 48px;
    border-radius: 0.75rem;
    display: flex; align-items: center; justify-content: center;
}
.metric-icon svg { width: 24px; height: 24px; color: #fff; }

.bg-indigo { background: #4f46e5; }
.bg-emerald { background: #059669; }
.bg-amber { background: #d97706; }
.bg-rose { background: #e11d48; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex; flex-wrap: wrap;
    align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 2rem; font-weight: 700; }
.page-header p { color: #94a3b8; margin-top: 0.25rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block; font-size: 0.875rem; font-weight: 500;
    color: #94a3b8; margin-bottom: 0.375rem;
}

input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], input[type="password"], input[type="date"],
input[type="search"], select, textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: rgba(15,23,42,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.5rem;
    color: #f8fafc;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

select { cursor: pointer; }
select option { background: #0f172a; color: #f8fafc; }

textarea { min-height: 80px; resize: vertical; }

/* Inline select (filtri) */
.filter-select {
    width: auto; min-width: 120px;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: rgba(15,23,42,0.5);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none; border-radius: 0.5rem;
    font-size: 0.875rem; font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer; transition: all 0.2s;
    text-decoration: none;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; box-shadow: 0 0 15px rgba(99,102,241,0.5); }

.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }

.btn-danger { background: #e11d48; color: #fff; }
.btn-danger:hover { background: #be123c; }

.btn-ghost {
    background: transparent; color: #94a3b8;
    border: 1px solid rgba(255,255,255,0.1);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: #f8fafc; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-icon { padding: 0.5rem; }

/* Toggle buttons row */
.toggle-group {
    display: flex; gap: 0;
    background: rgba(15,23,42,0.5);
    border-radius: 0.75rem;
    padding: 0.25rem;
    border: 1px solid rgba(255,255,255,0.1);
}
.toggle-btn {
    padding: 0.5rem 0.75rem;
    border: none; border-radius: 0.5rem;
    background: transparent;
    color: #94a3b8; cursor: pointer;
    font-size: 0.8rem; font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}
.toggle-btn:hover { color: #f8fafc; }
.toggle-btn.active { background: #4f46e5; color: #fff; }

/* ===== TABLES ===== */
.table-wrap {
    border-radius: 1rem;
    border: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
    background: rgba(15,23,42,0.2);
    backdrop-filter: blur(5px);
}

table { width: 100%; border-collapse: collapse; }

thead th {
    background: rgba(255,255,255,0.05);
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.875rem;
}
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr:last-child td { border-bottom: 0; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #64748b; }
.text-sm { font-size: 0.8rem; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-paid { background: rgba(16,185,129,0.2); color: #10b981; }
.badge-unpaid { background: rgba(239,68,68,0.2); color: #ef4444; }
.badge-overdue { background: rgba(245,158,11,0.2); color: #f59e0b; }
.badge-partial { background: rgba(251,191,36,0.2); color: #fbbf24; }

.badge-heliora { background: rgba(99,102,241,0.2); color: #818cf8; padding: 0.2rem 0.5rem; border-radius: 0.375rem; font-size: 0.75rem; font-weight: 600; }
.badge-orsa { background: rgba(16,185,129,0.2); color: #10b981; padding: 0.2rem 0.5rem; border-radius: 0.375rem; font-size: 0.75rem; font-weight: 600; }
.badge-heila { background: rgba(245,158,11,0.2); color: #f59e0b; padding: 0.2rem 0.5rem; border-radius: 0.375rem; font-size: 0.75rem; font-weight: 600; }

.badge-income { background: rgba(16,185,129,0.2); color: #34d399; }
.badge-expense { background: rgba(239,68,68,0.2); color: #f87171; }
.badge-transfer { background: rgba(59,130,246,0.2); color: #60a5fa; }
.badge-adjustment { background: rgba(168,85,247,0.2); color: #c084fc; }
.badge-issued { background: rgba(16,185,129,0.2); color: #34d399; }
.badge-received { background: rgba(251,146,60,0.2); color: #fb923c; }

/* ===== FLASH MESSAGES ===== */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.flash-success { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.flash-error { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
    background: rgba(15,23,42,0.95);
    backdrop-filter: blur(40px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 1rem;
    padding: 1.5rem;
    width: 90%; max-width: 600px;
    max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ===== CHARTS (CSS only) ===== */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 200px; padding-top: 1rem; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; justify-content: flex-end; }
.bar {
    width: 100%; min-width: 8px;
    border-radius: 3px 3px 0 0;
    transition: height 0.5s ease;
    position: relative;
}
.bar.rvc { background: #6366f1; }
.bar.sales { background: #10b981; }
.bar-label { font-size: 0.65rem; color: #64748b; text-align: center; margin-top: 4px; white-space: nowrap; }
.bar-value { font-size: 0.6rem; color: #94a3b8; text-align: center; }

.chart-legend {
    display: flex; gap: 1rem; margin-top: 0.75rem;
    font-size: 0.8rem; color: #94a3b8;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 0.375rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* RVC trend simple line */
.trend-chart { position: relative; height: 160px; }
.trend-svg { width: 100%; height: 100%; }

/* ===== TOP CUSTOMERS ===== */
.customer-row {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem; border-radius: 0.75rem;
    background: rgba(255,255,255,0.05);
    transition: background 0.2s;
    margin-bottom: 0.5rem;
}
.customer-row:hover { background: rgba(255,255,255,0.08); }
.customer-rank {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; flex-shrink: 0;
}
.rank-1 { background: #f59e0b; }
.rank-2 { background: #94a3b8; }
.rank-3 { background: #92400e; }
.customer-info { flex: 1; min-width: 0; }
.customer-info .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.customer-info .company { font-size: 0.8rem; color: #94a3b8; }
.customer-rvc { text-align: right; flex-shrink: 0; }
.customer-rvc .amount { font-weight: 700; color: #818cf8; }
.customer-rvc .count { font-size: 0.75rem; color: #64748b; }

/* ===== GRID HELPERS ===== */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }

@media (min-width: 640px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.col-span-2 { grid-column: span 2; }
@media (max-width: 1023px) { .col-span-2 { grid-column: span 1; } }

.space-y > * + * { margin-top: 1.5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 0.75rem; }
.gap-3 { gap: 1rem; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== LOGIN ===== */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 1rem;
}
.login-card {
    width: 100%; max-width: 400px;
    padding: 2rem;
}
.login-card h1 { text-align: center; margin-bottom: 0.5rem; font-size: 1.75rem; }
.login-card .subtitle { text-align: center; color: #94a3b8; margin-bottom: 2rem; }
.login-error { color: #f87171; font-size: 0.875rem; margin-top: 0.5rem; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(15,23,42,0.5); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ===== SPINNER ===== */
.spinner {
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #6366f1;
    border-radius: 50%;
    width: 40px; height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center; color: #64748b;
    padding: 3rem 1rem;
    font-size: 0.95rem;
}

/* ===== CHECKBOX styled ===== */
input[type="checkbox"] {
    width: 1rem; height: 1rem;
    accent-color: #6366f1;
    cursor: pointer;
}

/* ===== RESPONSIVE TABLE ===== */
.table-responsive { overflow-x: auto; }

/* ===== SEARCH BAR ===== */
.search-box {
    position: relative;
}
.search-box input {
    padding-left: 2.5rem;
}
.search-box svg {
    position: absolute; left: 0.75rem; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: #64748b;
}
