:root {
    --bg-app: #f0f2f5;
    --bg-white: #ffffff;
    --primary: #6366f1;
    --primary-light: #e0e7ff;
    --text-dark: #1f2937;
    --text-gray: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
    --radius: 16px;
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-app);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 80px;
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 0;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.logo {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 50px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

.logo .dot {
    color: var(--primary);
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
    align-items: center;
}

.menu-item {
    font-size: 1.2rem;
    color: var(--text-gray);
    position: relative;
    padding: 10px;
    transition: 0.3s;
    border-radius: 12px;
}

.menu-item:hover,
.menu-item.active {
    color: var(--primary);
    background: var(--primary-light);
}

.menu-item.active::after {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.bottom-menu {
    margin-top: auto;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    position: relative;
}

/* SPA Views */
.page-view {
    display: none;
    animation: fade-in-view 0.4s ease-out;
}

.page-view.active {
    display: block;
}

@keyframes fade-in-view {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Analytics Stats */
.brain-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 15px;
}

.stat-box {
    background: var(--bg-app);
    padding: 15px;
    border-radius: 12px;
    flex: 1;
    text-align: center;
}

.stat-box h3 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 5px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}


/* Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.page-title h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.date {
    font-size: 0.9rem;
    color: var(--text-gray);
    font-weight: 500;
}

.search-bar {
    background: var(--bg-white);
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    width: 400px;
    position: relative;
}

.search-bar input {
    border: none;
    outline: none;
    width: 100%;
    font-family: var(--font-main);
}

.search-bar i {
    color: var(--text-gray);
}

.ai-badge {
    position: absolute;
    right: 5px;
    top: 5px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    font-size: 0.65rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
}

.profile-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.icon-btn {
    font-size: 1.2rem;
    color: var(--text-gray);
    position: relative;
    cursor: pointer;
}

.badg {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.6rem;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.profile-pic img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: var(--shadow-md);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto auto auto;
    /* Allow more rows */
    gap: 25px;
    padding-bottom: 80px;
}

/* Cards Generic */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 1.1rem;
    color: var(--text-dark);
}

.card-header i {
    color: var(--primary);
    margin-right: 8px;
}

/* Specific Widgets */

/* 1. AI Pricing */
.card-wide.ai-pricing {
    grid-column: span 2;
    background: linear-gradient(135deg, #fff 0%, #fefaff 100%);
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.suggestion {
    display: flex;
    align-items: center;
    background: var(--bg-app);
    padding: 15px;
    border-radius: 12px;
    margin-top: 10px;
    gap: 15px;
}

.prod-icon {
    font-size: 2rem;
}

.prod-info {
    flex: 1;
}

.prod-info strong {
    display: block;
}

.prod-info small {
    color: var(--success);
    font-weight: 600;
}

.price-action {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.old-price {
    text-decoration: line-through;
    color: var(--text-gray);
    font-size: 0.9rem;
}

.new-price {
    color: var(--primary);
    font-size: 1.2rem;
}

.pricing-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
    transition: 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #4f46e5;
}

.btn-outline {
    border: 1px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-text {
    background: transparent;
    color: var(--text-gray);
}

.full-width {
    width: 100%;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* 2. Sales Summary */
.card-square {
    grid-column: span 1;
}

.big-number {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 10px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    transition: color 0.3s;
}

.pulse-green {
    color: var(--success);
    transform: scale(1.05);
}

.trend {
    font-size: 0.9rem;
    font-weight: 600;
}

.trend.up {
    color: var(--success);
}

.mini-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 60px;
    margin: 15px 0;
}

.bar {
    flex: 1;
    background: var(--primary-light);
    border-radius: 4px 4px 0 0;
    transition: 0.3s;
}

.bar.current {
    background: var(--primary);
}

.bar:hover {
    opacity: 0.8;
}

.insight-text {
    font-size: 0.85rem;
    color: var(--text-gray);
}

/* NEW: Card Tall for Activity */
.card-tall {
    grid-column: span 1;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
}

.activity-list {
    list-style: none;
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    animation: slide-in 0.4s ease-out;
}

.activity-item.new-item {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 8px;
    padding: 8px;
    border: none;
}

.act-icon {
    font-size: 1.5rem;
}

.act-info {
    flex: 1;
}

.act-info strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.act-info small {
    color: var(--text-gray);
    font-size: 0.75rem;
}

.act-price {
    color: var(--success);
    font-weight: 700;
    font-size: 0.9rem;
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 3. Smart Stock */
.stock-list {
    list-style: none;
}

.stock-list li {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.95rem;
}

.stock-val {
    font-weight: 700;
    color: var(--text-gray);
}

.stock-val.low {
    color: var(--danger);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* 4. Demand Prediction */
.card-wide.prediction-chart {
    grid-column: span 2;
}

.chart-container {
    height: 150px;
    position: relative;
}

.smooth-chart {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.pulsing-dot {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        r: 6;
        opacity: 1;
    }

    50% {
        r: 10;
        opacity: 0.5;
    }

    100% {
        r: 6;
        opacity: 1;
    }
}

.chart-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 5px;
    font-size: 0.8rem;
    color: var(--text-gray);
    margin-top: 5px;
}

/* 5. Customer Profile */
.customer-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.avatar {
    width: 50px;
    height: 50px;
    background: var(--warning);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
}

.cust-stats {
    display: flex;
    justify-content: space-between;
    background: var(--bg-app);
    padding: 15px;
    border-radius: 12px;
}

.cust-stats div {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.cust-stats strong {
    font-size: 1.1rem;
}

/* 6. FAB */
.camera-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 100;
}

.fab-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--text-dark);
    color: white;
    border: none;
    font-size: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-btn:hover {
    transform: scale(1.1) rotate(90deg);
    background: var(--primary);
}

.tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: 0.3s;
    pointer-events: none;
    white-space: nowrap;
}

.camera-fab:hover .tooltip {
    opacity: 1;
    right: 80px;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 200;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-left: 4px solid var(--primary);
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left-color: var(--success);
}

.toast-warning {
    border-left-color: var(--warning);
}

.toast i {
    font-size: 1.2rem;
    color: var(--text-dark);
}


/* 7. Cash Flow */
.cash-flow .card-header {
    align-items: flex-start;
}

.cash-legend {
    font-size: 0.8rem;
    color: var(--text-gray);
    display: flex;
    gap: 10px;
}

.dot-l {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-l.sales {
    background: var(--success);
}

.dot-l.costs {
    background: var(--danger);
}

.cash-summary {
    display: flex;
    justify-content: space-between;
    background: var(--bg-app);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    gap: 10px;
}

.cash-summary div {
    display: flex;
    flex-direction: column;
    flex: 1;
    text-align: center;
}

.cash-summary small {
    color: var(--text-gray);
    font-size: 0.8rem;
}

.c-val {
    font-weight: 700;
    font-size: 1rem;
}

.c-val.success {
    color: var(--success);
}

.c-val.danger {
    color: var(--danger);
}

.c-val.neutral {
    color: var(--text-dark);
}

.cf-chart-container {
    height: 120px;
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
}

.cf-bar-group {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    height: 100%;
    position: relative;
    width: 30px;
    justify-content: center;
}

.cf-bar {
    width: 8px;
    border-radius: 4px 4px 0 0;
    transition: 0.4s;
}

.cf-bar.in {
    background: var(--success);
}

.cf-bar.out {
    background: rgba(239, 68, 68, 0.5);
}

.week-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-gray);
}

/* 8. Clustering */
.clustering .card-header {
    margin-bottom: 10px;
}

.minimal-select {
    border: none;
    background: transparent;
    font-family: var(--font-main);
    color: var(--text-gray);
    font-size: 0.85rem;
    cursor: pointer;
}

.scatter-container {
    position: relative;
    height: 160px;
}

.scatter-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.cluster-dot {
    animation: float-dot 3s ease-in-out infinite;
    transform-origin: center;
}

.move-1 {
    animation-delay: 0s;
}

.move-2 {
    animation-delay: 1s;
    animation-duration: 4s;
}

.move-3 {
    animation-delay: 0.5s;
    animation-duration: 2.5s;
}

@keyframes float-dot {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.cluster-labels {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 5px;
    font-size: 0.8rem;
}

.cl-label.risk {
    color: #ef4444;
}

.cl-label.regular {
    color: #6366f1;
}

.cl-label.vip {
    color: #10b981;
}

/* 9. Analytics Grid Expansion */
.analytics-grid-6 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding-bottom: 40px;
}

.chart-desc {
    font-size: 0.8rem;
    color: var(--text-gray);
    margin-bottom: 15px;
    height: 30px;
    /* fixed height for alignment */
}

.chart-box {
    height: 120px;
    background: var(--bg-app);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.card h4 {
    font-size: 0.95rem;
    color: var(--text-dark);
}

/* Heatmap */
.heatmap-container {
    flex-direction: column;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* 4x4 Grid */
    gap: 4px;
    width: 100px;
    /* Wider */
    height: 100px;
}

.h-cell {
    background: var(--primary);
    border-radius: 4px;
    transition: opacity 1s;
    animation: pulse-cell 3s infinite alternate;
}

@keyframes pulse-cell {
    from {
        opacity: 0.2;
    }

    to {
        opacity: 0.8;
    }
}

/* NLP Bar */
.flex-bar {
    gap: 10px;
    align-items: flex-end;
}

.nlp-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    flex: 1;
    justify-content: flex-end;
}

.n-seg {
    width: 100%;
    border-radius: 4px 4px 0 0;
}

.n-seg.pos {
    background: var(--success);
}

.n-seg.neu {
    background: var(--text-gray);
}

.n-seg.neg {
    background: var(--danger);
}

.nlp-bar span {
    font-size: 0.7rem;
    margin-top: 5px;
}

/* Mini Legends */
.mini-legend {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 0.65rem;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 5px;
    border-radius: 4px;
}

.mini-stats {
    display: flex;
    gap: 10px;
    font-size: 0.7rem;
    position: absolute;
    bottom: 10px;
    width: 100%;
    justify-content: center;
}

.compact li {
    padding: 8px 0;
}

.danger-row {
    font-size: 0.8rem;
}

.pulse-text {
    animation: pulse-text 2s infinite;
}

@keyframes pulse-text {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
        color: var(--primary);
    }

    100% {
        transform: scale(1);
    }
}

/* Responsive Grid */
@media (max-width: 1100px) {
    .analytics-grid-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .analytics-grid-6 {
        grid-template-columns: 1fr;
    }
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    color: var(--text-gray);
    font-weight: 500;
    padding: 12px;
    border-bottom: 2px solid #eee;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    color: var(--text-dark);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: #fafafa;
}

.badge-tag {
    background: var(--primary-light);
    color: var(--primary);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-done {
    color: var(--success);
    font-weight: 600;
    font-size: 0.85rem;
}

.status-warn {
    color: var(--danger);
    font-weight: 600;
    font-size: 0.85rem;
}

.status-pending {
    color: var(--warning);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Customer NBA View */
.custom-section-title {
    margin-bottom: 25px;
}

.custom-section-title h3 {
    font-size: 1.3rem;
    margin-bottom: 5px;
    color: var(--text-dark);
}

.custom-section-title p {
    color: var(--text-gray);
    font-size: 0.9rem;
}

.customer-nba-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.nba-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-top: 4px solid transparent;
}

.nba-card.border-danger {
    border-top-color: var(--danger);
}

.nba-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.user-info div {
    display: flex;
    flex-direction: column;
}

.user-info strong {
    font-size: 0.95rem;
}

.score-circle {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 3px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-dark);
}

.nba-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
}

.insight-row {
    display: flex;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-gray);
    align-items: flex-start;
}

.insight-row i {
    color: var(--primary);
    margin-top: 3px;
}

.recommendation-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 8px;
}

.recommendation-box small {
    display: block;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.7rem;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.recommendation-box strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.recommendation-box.warning small {
    color: var(--danger);
}

.recommendation-box.info small {
    color: #f59e0b;
}

.discount-logic {
    font-size: 0.75rem;
    color: var(--text-gray);
    display: flex;
    justify-content: space-between;
    background: #fff;
    padding: 5px 0;
}

.action-text {
    font-weight: 600;
    color: var(--text-dark);
}

@media (max-width: 1000px) {
    .customer-nba-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-wide {
        grid-column: span 2;
    }

    .card-square {
        grid-column: span 1;
    }

    .card-tall {
        grid-column: span 1;
    }

    /* adjust if needed */
    .top-bar {
        flex-wrap: wrap;
        gap: 20px;
    }

    .search-bar {
        width: 100%;
        order: 3;
    }
}

@media (max-width: 600px) {
    .sidebar {
        width: 0;
        padding: 0;
        border: none;
        overflow: hidden;
    }

    .main-content {
        padding: 20px;
    }

    .dashboard-grid {
        display: flex;
        flex-direction: column;
    }

    .card-wide,
    .card-square,
    .card-tall {
        width: 100%;
    }

    .analytics-grid-6 {
        grid-template-columns: 1fr;
    }
}