/* ============================================================
   DASHBOARD - Modern Professional UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sidebar-width: 260px;
    --topbar-height: 65px;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #243447;
    --border-color: rgba(255, 255, 255, 0.07);
    --text-primary: #586470;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-cyan: #06b6d4;
    --gradient-blue: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-green: linear-gradient(135deg, #10b981, #059669);
    --gradient-orange: linear-gradient(135deg, #f59e0b, #ef4444);
    --gradient-cyan: linear-gradient(135deg, #06b6d4, #3b82f6);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius-card: 16px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.5rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-blue);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    flex-shrink: 0;
}

.brand-logo {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.brand-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.brand-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0.8rem 0.75rem 0.4rem;
    margin-top: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.nav-item:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background: var(--accent-blue);
    border-radius: 0 3px 3px 0;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.nav-item span:first-of-type {
    flex: 1;
}

.nav-badge {
    background: var(--accent-red);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    line-height: 1.4;
    display: none;
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.5rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--gradient-blue);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.logout-btn {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.3rem;
    border-radius: 6px;
    transition: var(--transition);
    flex-shrink: 0;
}

.logout-btn:hover {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-layout {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    display: none;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.breadcrumb-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
}

.topbar-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.topbar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.notification-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 300px;
    box-shadow: var(--shadow-card);
    padding: 0;
    overflow: hidden;
}

.dropdown-header {
    padding: 0.85rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    background: var(--gradient-purple, linear-gradient(135deg, #8b5cf6, #3b82f6));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

/* STAT CARDS */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--card-accent, rgba(59, 130, 246, 0.08));
    transform: translate(20px, -20px);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    margin-bottom: 1rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    font-weight: 600;
}

.stat-change.up {
    color: var(--accent-green);
}

.stat-change.down {
    color: var(--accent-red);
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
    color: var(--text-primary);
}

.table th {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

.table td {
    border-bottom: 1px solid var(--border-color);
    padding: 0.9rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.35em 0.75em;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.badge-secondary {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

.badge-info {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.badge-purple {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}

.badge-dark {
    background: rgba(30, 41, 59, 0.5);
    color: #2773de;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--gradient-blue);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    color: white;
}

.btn-success {
    background: var(--gradient-green);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    transform: translateY(-1px);
    color: white;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    color: var(--accent-red);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    border-radius: 7px;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-control,
.form-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 9px;
    color: var(--text-primary);
    padding: 0.55rem 0.9rem;
    font-size: 0.875rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    color: var(--text-primary);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-select {
    background-image: none !important;
    appearance: none;
    -webkit-appearance: none;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.input-group-text {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.modal-title {
    font-weight: 700;
    color: var(--text-primary);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

.btn-close {
    filter: invert(1);
}

/* ============================================================
   CHAT UI
   ============================================================ */
.chat-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: calc(100vh - var(--topbar-height) - 3rem);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    overflow: hidden;
}

.chat-sidebar {
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-search {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.chat-list {
    overflow-y: auto;
    flex: 1;
}

.chat-list-item {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-list-item:hover {
    background: rgba(59, 130, 246, 0.08);
}

.chat-list-item.active {
    background: rgba(59, 130, 246, 0.12);
    border-right: 2px solid var(--accent-blue);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: var(--gradient-blue);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.chat-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message-bubble {
    max-width: 65%;
    padding: 0.65rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
}

.message-bubble.visitor {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-bubble.agent {
    background: var(--gradient-blue);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.message-meta.agent-meta {
    text-align: right;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.chat-input-area .form-control {
    border-radius: 12px;
    resize: none;
}

.btn-send {
    background: var(--gradient-blue);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* ============================================================
   ALERT
   ============================================================ */
.alert-container {
    padding: 0 1.5rem;
    padding-top: 1rem;
}

.alert-custom {
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    transition: opacity 0.5s;
}

.alert-success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #10b981;
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: #f59e0b;
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.7;
    padding: 0 0.25rem;
}

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1rem;
}

.filters-bar .form-control,
.filters-bar .form-select {
    max-width: 200px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    backdrop-filter: blur(3px);
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

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

/* ============================================================
   ORDER DETAIL
   ============================================================ */
.order-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.order-detail-row:last-child {
    border-bottom: none;
}

.order-detail-label {
    color: var(--text-muted);
}

.order-detail-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1001;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-layout {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex !important;
    }

    .chat-layout {
        grid-template-columns: 1fr;
    }

    .chat-sidebar {
        display: none;
    }

    .chat-sidebar.show {
        display: flex;
        position: absolute;
        width: 300px;
        height: 100%;
        z-index: 10;
        background: var(--bg-card);
    }

    .page-content {
        padding: 1rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }
}