/*
   CRM Pro - High End "Million Dollar" Aesthetic
   Based on Bento Grid Layout, Dark OLED Theme, and Precision Typography
*/

:root {
    /* Color Palette: Obsidian & Volt Green (Reference Inspired) */
    --bg-app: #0c0c0c;
    /* Deep obsidian */
    --bg-card: #141414;
    /* Slightly elevated */
    --bg-elevated: #1e1e1e;
    /* Higher elevation */
    --border: #262626;
    /* Subtle dark border */
    --border-subtle: rgba(255, 255, 255, 0.03);

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-tertiary: #52525b;

    /* Accents - Vibrant Lime/Volt */
    --accent: #c1ff72;
    --accent-muted: rgba(193, 255, 114, 0.1);
    --primary: #c1ff72;
    --primary-hover: #d2ff8a;

    /* Functional Colors */
    --success: #c1ff72;
    --warning: #fbbf24;
    --danger: #ff4b4b;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

/* Base Layout: Sidebar + Content */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Main Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    height: 100vh;
    overflow: hidden;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    padding: 0.75rem 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.02);
    position: relative;
    overflow: hidden;
}

.top-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
    opacity: 0.3;
}

.top-bar-brand {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-icon {
    font-size: 1.75rem;
    color: var(--accent);
    filter: drop-shadow(0 0 10px var(--accent-muted));
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-utils-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-right: 1px solid var(--border);
    padding-right: 1rem;
    margin-right: 0.5rem;
}

.nav-item-header {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    text-decoration: none;
}

.nav-item-header:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.contact-link {
    width: auto !important;
    padding: 0 12px;
    gap: 8px;
    color: #25D366 !important;
    background: rgba(37, 211, 102, 0.05) !important;
    border: 1px solid rgba(37, 211, 102, 0.1) !important;
}

.contact-number {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.nav-item-header.profile {
    display: flex;
    align-items: center;
    gap: 10px;
    width: auto;
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-item-header.profile img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--accent);
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}


.system-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-sep {
    color: var(--text-tertiary);
    opacity: 0.5;
}

.title-accent {
    color: var(--accent);
    opacity: 0.9;
}

/* Buttons */
.btn-primary {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 0.7rem 1.4rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-muted);
}

/* Main Content - Tightened for Single View */
body {
    height: 100vh;
    overflow: hidden;
    /* Strict no-scroll for desktop */
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    /* Reduced padding */
    height: 100vh;
    overflow: hidden;
}

.top-bar {
    margin-bottom: 1.5rem;
}

/* BENTO GRID - Optimized for 100vh Single Screen */
.bento-grid {
    flex: 1;
    /* Take remaining height */
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 150px 1fr 1.2fr;
    /* Explicit ratios to fit screen */
    gap: 1.25rem;
    height: 100%;
    min-height: 0;
    /* Critical for flex child overflow */

    grid-template-areas:
        "revenue mrr ticket year"
        "chart chart chart goals"
        "list list list list";
}

/* Common Card Styles - Dense Mode */
.bento-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 1.25rem;
    position: relative;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Allow shrinking */
}

/* Specific Areas Heights Management */
.area-revenue,
.area-mrr,
.area-ticket,
.area-year {
    min-height: 0;
}

.area-revenue {
    grid-area: revenue;
}

.area-mrr {
    grid-area: mrr;
}

.area-ticket {
    grid-area: ticket;
}

.area-year {
    grid-area: year;
}

.area-chart {
    grid-area: chart;
}

.area-goals {
    grid-area: goals;
}

.area-list {
    grid-area: list;
    overflow: hidden;
}

/* Table must handle its own scroll */

/* KPI Styling */
.card-header-sm {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    /* Increased margin */
}

.label {
    font-size: 0.75rem;
    /* Slightly smaller label */
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.trend {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(52, 211, 153, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
}

.kpi-value-lg {
    font-size: 2.25rem;
    /* Reduced to fit */
    font-weight: 700;
    letter-spacing: -0.04rem;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.kpi-value-md {
    font-size: 1.75rem;
    /* Slightly reduced */
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.kpi-chart-mini {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    /* Reduced gap */
    height: 32px;
    /* Fixed height for mini chart */
    margin-top: auto;
}

.bar {
    flex: 1;
    /* Bars fill the space */
    min-width: 4px;
    max-width: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    transition: background 0.3s ease, height 0.3s ease;
}

.bar.active {
    background: var(--text-primary);
    opacity: 1;
}

.sub-text {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Circular Progress */
.progress-ring {
    width: 50px;
    height: 50px;
    position: absolute;
    right: 20px;
    bottom: 20px;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 100%;
}

.circle-bg {
    fill: none;
    stroke: var(--bg-elevated);
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.8;
    stroke-linecap: round;
    filter: drop-shadow(0 0 5px var(--accent-muted));
    animation: progress 1s ease-out forwards;
}

@keyframes progress {
    0% {
        stroke-dasharray: 0 100;
    }
}

/* Chart Section */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.tab-pill {
    background: var(--bg-elevated);
    border-radius: 10px;
    padding: 4px;
    display: flex;
}

.tab-pill span {
    padding: 4px 14px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.tab-pill span.active {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Performance Monthly Bars (Modern Minimalist) */
.performance-bars-container {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 1.5rem;
    padding-bottom: 0.5rem;
    height: 100%;
    min-height: 0;
}

.performance-month-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    height: 100%;
    justify-content: flex-end;
}

.performance-bar-fine {
    width: 6px;
    background: var(--bg-elevated);
    border-radius: 4px;
    height: 0%;
    /* Dynamic */
    transition: height 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.performance-bar-fine.active {
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent-muted);
}

.month-label-sm {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-weight: 700;
    text-transform: uppercase;
}

/* Gamified Goals Style */
.gamified-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    height: 100%;
}

.level-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-badge {
    padding: 4px 10px;
    border-radius: 50px;
    background: var(--accent);
    color: #000;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.level-xp-text {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.progress-tracks {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.track-line {
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 10px;
    overflow: hidden;
}

.track-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    box-shadow: 0 0 10px var(--accent-muted);
    transition: width 1s ease;
}

.chart-wrapper {
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* Goals Section */
.goal-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
    gap: 1.25rem;
}

.goal-circle {
    width: 130px;
    height: 130px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
}

.goal-circle svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.goal-circle circle {
    fill: none;
    stroke-width: 9;
    stroke-linecap: round;
}

.goal-circle .bg {
    stroke: var(--bg-elevated);
}

.goal-circle .progress {
    stroke: var(--accent);
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    filter: drop-shadow(0 0 8px var(--accent-muted));
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.goal-text {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.target-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.target-value {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.percentage-badge {
    background: var(--accent-muted);
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    border: 1px solid rgba(0, 255, 137, 0.2);
}

.meta-stats {
    margin: 15px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* List Section */
.list-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    /* Prevent overflow */
}

.search-box {
    position: relative;
    background: var(--bg-elevated);
    border-radius: 8px;
    display: flex;
    align-items: center;
    width: 100%;
    /* Flexible width */
    max-width: 220px;
}

.search-box i {
    position: absolute;
    left: 10px;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px 8px 8px 32px;
    width: 100%;
    font-size: 0.85rem;
    outline: none;
}

.filter-pills .pill {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
}

.filter-pills .pill:hover {
    border-color: var(--text-secondary);
}

.filter-pills .pill.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: 700;
}

/* Premium Table */
/* Table internal scrolling for Bento */
.custom-table-container {
    flex: 1;
    overflow-y: auto;
    /* Sub-scrolling within the grid */
    min-height: 0;
}

.custom-table-container::-webkit-scrollbar {
    width: 6px;
}

.custom-table-container::-webkit-scrollbar-track {
    background: transparent;
}

.custom-table-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
}

.premium-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.premium-table td {
    padding: 1.2rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.premium-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Buttons in table */
.btn-icon-sm {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-icon-sm:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-whatsapp {
    color: #25D366 !important;
    background: rgba(37, 211, 102, 0.1) !important;
    border-color: rgba(37, 211, 102, 0.2) !important;
}

.btn-whatsapp:hover {
    background: rgba(37, 211, 102, 0.2) !important;
    box-shadow: 0 0 15px rgba(37, 211, 102, 0.2);
}

/* Modal High End */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-window {
    background: #121215;
    border: 1px solid var(--border);
    width: 450px;
    padding: 2rem;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .modal-window {
    transform: translateY(0);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-head h2 {
    font-size: 1.25rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.2rem;
    cursor: pointer;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input,
.select-wrapper select {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border 0.2s;
}

.input-group input:focus,
.select-wrapper select:focus {
    border-color: var(--text-secondary);
}

.col-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
}

/* Toast */
.toast-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--bg-app);
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 200;
}

.toast-notification.active {
    transform: translateX(-50%) translateY(0);
}

/* Responsive Bento */
@media (max-width: 1024px) {
    .bento-grid {
        grid-template-areas:
            "revenue revenue"
            "mrr year"
            "chart chart"
            "goals goals"
            "list list";
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        overflow: hidden;
    }

    .sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        padding: 0 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        justify-content: space-between;
    }

    .nav-items {
        flex-direction: row;
        gap: 0.5rem;
        justify-content: center;
    }

    .nav-utils {
        display: none;
    }

    /* Simplify for mobile */

    .bento-grid {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .bento-grid>div {
        min-height: auto;
    }

    .area-chart {
        min-height: 250px;
    }
}