/* ══════════════════════════════════════════════════════════════════════════════
   INTAPRICE AI — Dashboard Styles
   ════════════════════════════════════════════════════════════════════════─═════ */

.dashboard-layout {
    display: flex;
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(108, 99, 255, 0.08), transparent 35%),
        radial-gradient(circle at top left, rgba(0, 208, 132, 0.07), transparent 30%),
        var(--bg-dark);
    color-scheme: dark;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
    width: 264px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(17, 24, 39, 0.9));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition-slow);
    backdrop-filter: blur(6px);
    contain: layout paint;
}

.sidebar-header {
    padding: 32px 24px;
}

.sidebar-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-nav {
    flex: 1;
    padding: 0 14px;
    list-style: none;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 600;
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--border);
    transform: translateX(2px);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(0, 208, 132, 0.16), rgba(0, 208, 132, 0.05));
    color: #8bf7cc;
    border-color: rgba(0, 208, 132, 0.24);
    box-shadow: inset 3px 0 0 rgba(0, 208, 132, 0.9);
}

.nav-link.active .nav-icon {
    color: #b5ffe2;
    transform: scale(1.03);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
}

.user-snippet {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-card-2);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    display: block;
}

.user-plan {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
}

/* ── Main Content ──────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0));
}

.top-bar {
    height: 72px;
    background: rgba(10, 14, 26, 0.82);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
    backdrop-filter: blur(6px);
}

.page-title {
    font-size: clamp(1.2rem, 1.4vw, 1.45rem);
    font-weight: 700;
    letter-spacing: 0.2px;
}

.content-body {
    padding: 28px 32px 36px;
    flex: 1;
    overflow-y: auto;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* Improves perceived load by skipping offscreen rendering work */
.content-body > * {
    content-visibility: auto;
    contain-intrinsic-size: 1px 520px;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.welcome-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 22px;
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
}

.welcome-box h2 {
    font-size: clamp(1.3rem, 1.8vw, 1.7rem);
}

/* ── Dashboard Cards ────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.chart-section {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 28px;
}

.main-content .card {
    border-radius: 14px;
    padding: 20px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.main-content .card:hover {
    transform: translateY(-1px);
}

.main-content .card h3 {
    font-size: 1.05rem;
}

.stat-card {
    padding: 20px;
}

.stat-number {
    font-size: clamp(1.55rem, 1.8vw, 1.95rem);
}

.btn {
    letter-spacing: 0.1px;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.01);
}

.btn-sm {
    min-height: 40px;
}

.top-bar-actions .btn {
    min-height: 38px;
}

.main-content table {
    width: 100%;
}

.main-content thead th {
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--text-muted);
}

.main-content tbody tr {
    transition: var(--transition);
}

.main-content tbody tr:hover {
    background: rgba(255, 255, 255, 0.015);
}

.main-content table {
    border-collapse: collapse;
}

.main-content tbody td {
    color: #d4d9e2;
}

.inbox-layout {
    border-radius: 14px;
}

.convo-item {
    border-left: 2px solid transparent;
    border-radius: 10px;
    margin: 4px 8px;
    border: 1px solid transparent;
}

.convo-item.active {
    border-left: 2px solid var(--primary);
    border-color: rgba(0, 208, 132, 0.2);
    box-shadow: inset 0 0 0 1px rgba(0, 208, 132, 0.15);
}

.chat-bubble {
    line-height: 1.45;
}

.nav-link:focus-visible,
.btn:focus-visible,
.form-control:focus-visible {
    outline: 2px solid rgba(0, 208, 132, 0.45);
    outline-offset: 2px;
}

/* ── Inbox Management ───────────────────────────────────────────────────── */
.inbox-layout {
    display: grid;
    grid-template-columns: 340px 1fr 300px;
    height: calc(100vh - 160px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.convo-list {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.convo-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.convo-items {
    flex: 1;
    overflow-y: auto;
}

.convo-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 12px;
}

.convo-item:hover {
    background: var(--bg-hover);
}

.convo-item.active {
    background: rgba(0, 208, 132, 0.05);
    border-left: 3px solid var(--primary);
}

.convo-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-card-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.convo-info {
    flex: 1;
    overflow: hidden;
}

.convo-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.convo-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.convo-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.convo-msg {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Chat View ──────────────────────────────────────────────────────────── */
.chat-view {
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overscroll-behavior: contain;
}

.chat-bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.chat-bubble-wrap.assistant {
    align-self: flex-start;
}

.chat-bubble-wrap.user {
    align-self: flex-end;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
}

.assistant .chat-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.user .chat-bubble {
    background: var(--primary);
    color: var(--text-inverse);
}

.chat-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    gap: 8px;
}

.chat-input-area {
    padding: 20px 24px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.ai-suggestion-box {
    background: rgba(108, 99, 255, 0.1);
    border: 1px dashed var(--secondary);
    padding: 12px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.input-wrap {
    display: flex;
    gap: 12px;
}

/* ── Detail Panel ───────────────────────────────────────────────────────── */
.detail-panel {
    padding: 24px;
    border-left: 1px solid var(--border);
    overflow-y: auto;
}

.detail-section {
    margin-bottom: 32px;
}

.detail-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

/* ── Chatbot Grid ───────────────────────────────────────────────────────── */
.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.bot-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.bot-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-light);
}

.bot-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--bg-card-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 24px;
}

/* ── Global Spinner Animation ──────────────────────────────────────────── */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* ── Luxury Golden Spinner ────────────────────────────────────────────── */
.spinner-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    width: 100%;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(181, 160, 85, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── Premium Select Dropdown Styling ──────────────────────────────────── */
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: rgba(15, 23, 42, 0.95);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23B5A055' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding: 10px 36px 10px 16px;
    cursor: pointer;
    border: 1px solid rgba(181, 160, 85, 0.25);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

select.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(181, 160, 85, 0.15);
}

select.form-control option {
    background-color: #0f172a;
    color: #e2e8f0;
    padding: 8px;
}

/* ── Mobile Sidebar Toggle ────────────────────────────────────────────── */
.sidebar-toggle {
    display: none;
    background: rgba(181, 160, 85, 0.1);
    border: 1px solid rgba(181, 160, 85, 0.25);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1.25rem;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    margin-right: 12px;
}

.sidebar-toggle:hover {
    background: rgba(181, 160, 85, 0.2);
    border-color: var(--primary);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 9, 18, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1005;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.mobile-back-btn {
    display: none !important;
}

/* ── Responsive Dashboard ─────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-section {
        grid-template-columns: 1fr;
    }

    .inbox-layout {
        grid-template-columns: 300px 1fr;
    }

    .detail-panel {
        display: none;
    }
}

@media (max-width: 992px) {
    .sidebar {
        width: 220px;
    }

    .top-bar {
        padding: 0 20px;
    }

    .content-body {
        padding: 20px;
    }

    .top-bar {
        height: auto;
        min-height: 72px;
        padding-top: 12px;
        padding-bottom: 12px;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -264px;
        top: 0;
        bottom: 0;
        width: 264px;
        z-index: 1010;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        height: 100vh;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        transform: translateX(264px);
    }

    .user-info,
    .sidebar-logo > span,
    .nav-link > span:not(.nav-icon) {
        display: inline !important;
    }

    .sidebar-header,
    .sidebar-footer {
        padding: 24px 20px;
        display: flex;
        justify-content: flex-start;
    }

    .nav-link {
        justify-content: flex-start;
        min-height: 48px;
        padding: 12px 16px;
    }

    .top-bar {
        padding: 0 20px;
    }

    .content-body {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Inbox Mobile view-switching logic */
    .inbox-layout {
        grid-template-columns: 1fr;
        position: relative;
        overflow: hidden;
    }

    .convo-list {
        display: block;
    }

    .chat-view {
        display: none;
    }

    .inbox-layout.show-chat .convo-list {
        display: none;
    }

    .inbox-layout.show-chat .chat-view {
        display: flex;
    }

    .mobile-back-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    .convo-item {
        margin: 2px 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

@media (prefers-reduced-data: reduce) {
    .dashboard-layout {
        background: var(--bg-dark);
    }

    .sidebar,
    .top-bar {
        backdrop-filter: none;
    }
}

/* ── Responsive Helper Grids ─────────────────────────────────────────── */
.grid-layout-two-cols {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 40px;
}

.grid-layout-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 992px) {
    .grid-layout-two-cols {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 576px) {
    .grid-layout-half {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}