/* ============================================================
   QuoteX AI - Admin Panel Stylesheet
   Modern B2B SaaS UI - Pure CSS, no frameworks
   ============================================================ */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --secondary: #7c3aed;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);

    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: .2s ease;
}

html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-sans); color: var(--gray-800); background: var(--gray-50); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
table { border-collapse: collapse; width: 100%; }

/* === LAYOUT === */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition);
}
.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-header .logo { font-size: 1.25rem; font-weight: 700; color: #fff; }
.sidebar-header .logo span { color: var(--primary); }

.sidebar-nav { padding: 16px 0; }
.sidebar-section { padding: 8px 24px; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gray-400); margin-top: 8px; }

.sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 24px;
    color: var(--gray-300);
    font-size: .9rem; font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: rgba(37,99,235,.15); color: var(--primary-light); border-left-color: var(--primary); }
.sidebar-link .icon { width: 20px; text-align: center; opacity: .7; }
.sidebar-link .badge-count {
    margin-left: auto; background: var(--danger); color: #fff;
    font-size: .7rem; padding: 2px 7px; border-radius: 10px; font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-left h1 { font-size: 1.2rem; font-weight: 600; color: var(--gray-900); }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px; border-radius: var(--radius);
    cursor: pointer; transition: background var(--transition);
}
.topbar-user:hover { background: var(--gray-100); }
.topbar-user .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .85rem;
}
.topbar-user .name { font-weight: 500; color: var(--gray-700); font-size: .9rem; }

.btn-icon {
    width: 38px; height: 38px; border-radius: var(--radius);
    border: 1px solid var(--gray-200); background: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all var(--transition); position: relative;
}
.btn-icon:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-icon .notif-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; }

/* Page Content */
.page-content { padding: 32px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--gray-500); margin-bottom: 8px; }
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--gray-300); }

/* === CARDS === */
.card {
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow); border: 1px solid var(--gray-100);
    overflow: hidden;
}
.card-header {
    padding: 20px 24px; border-bottom: 1px solid var(--gray-100);
    display: flex; justify-content: space-between; align-items: center;
}
.card-header h3 { font-size: 1.05rem; font-weight: 600; }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card {
    background: #fff; border-radius: var(--radius-lg);
    padding: 24px; box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    display: flex; justify-content: space-between; align-items: flex-start;
}
.stat-card .stat-info { }
.stat-card .stat-label { font-size: .8rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--gray-900); margin-top: 4px; }
.stat-card .stat-change { font-size: .8rem; margin-top: 4px; }
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.yellow { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: var(--secondary); }
.stat-icon.cyan { background: #cffafe; color: var(--info); }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius);
    font-size: .9rem; font-weight: 600; font-family: var(--font-sans);
    border: 1px solid transparent; cursor: pointer;
    transition: all var(--transition); line-height: 1.4;
    text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: 8px; }

/* === FORMS === */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; font-size: .9rem; }
.form-group .hint { font-size: .78rem; color: var(--gray-400); margin-top: 4px; }

.form-control {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: .9rem; font-family: var(--font-sans);
    transition: all var(--transition); background: #fff;
    color: var(--gray-800);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-control.error { border-color: var(--danger); }

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

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

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

.data-table { width: 100%; }
.data-table th {
    text-align: left; padding: 12px 16px;
    font-size: .78rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--gray-500); background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}
.data-table td {
    padding: 14px 16px; border-bottom: 1px solid var(--gray-100);
    font-size: .9rem; color: var(--gray-700);
    vertical-align: middle;
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table .actions { white-space: nowrap; }
.data-table .actions a, .data-table .actions button { margin-right: 8px; }

/* === BADGES === */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 20px;
    font-size: .75rem; font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #cffafe; color: #155e75; }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* === ALERTS === */
.alert {
    padding: 14px 20px; border-radius: var(--radius);
    margin-bottom: 20px; display: flex; align-items: center; gap: 10px;
    font-size: .9rem; font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.alert .close-alert {
    margin-left: auto; cursor: pointer; background: none; border: none;
    font-size: 1.2rem; opacity: .6; color: inherit;
}
.alert .close-alert:hover { opacity: 1; }

/* === PAGINATION === */
.pagination { display: flex; align-items: center; gap: 4px; justify-content: center; margin-top: 24px; }
.pagination a, .pagination span {
    padding: 8px 14px; border-radius: var(--radius);
    font-size: .85rem; font-weight: 500;
    border: 1px solid var(--gray-200);
    color: var(--gray-600); background: #fff;
    transition: all var(--transition);
}
.pagination a:hover { background: var(--gray-50); border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: .4; cursor: not-allowed; }

/* === TABS === */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 24px; gap: 0; }
.tab {
    padding: 12px 24px; font-weight: 600; font-size: .9rem;
    color: var(--gray-500); border-bottom: 2px solid transparent;
    margin-bottom: -2px; cursor: pointer; background: none; border-top: none; border-left: none; border-right: none;
    transition: all var(--transition);
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* === MODALS === */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
    max-height: 90vh; overflow-y: auto;
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* === DROPDOWN === */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: 100%; right: 0;
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 200px; padding: 6px;
    display: none; z-index: 50;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px; border-radius: 6px;
    font-size: .88rem; color: var(--gray-700);
    transition: background var(--transition);
}
.dropdown-item:hover { background: var(--gray-50); }
.dropdown-divider { height: 1px; background: var(--gray-200); margin: 4px 0; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center; padding: 60px 24px; color: var(--gray-400);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 16px; opacity: .5; }
.empty-state h3 { color: var(--gray-600); margin-bottom: 8px; }
.empty-state p { font-size: .9rem; margin-bottom: 20px; }

/* === FILTERS === */
.filter-bar {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 20px;
}
.filter-bar .search-box { position: relative; flex: 1; min-width: 200px; }
.filter-bar .search-box input { padding-left: 38px; }
.filter-bar .search-box .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

/* === LOADING === */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: absolute; inset: 0;
    background: rgba(255,255,255,.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 10; border-radius: var(--radius-lg);
}

/* === RESPONSIVE === */
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--gray-600); }

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .page-content { padding: 20px; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
}

@media (max-width: 640px) {
    .topbar { padding: 0 16px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .filter-bar { flex-direction: column; }
    .form-row { grid-template-columns: 1fr; }
    .btn-group { flex-wrap: wrap; }
}

/* === LOGIN PAGE === */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
    padding: 20px;
}
.login-card {
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 420px;
    padding: 40px;
}
.login-card .logo-area { text-align: center; margin-bottom: 32px; }
.login-card .logo-area h1 { font-size: 1.5rem; color: var(--gray-900); }
.login-card .logo-area h1 span { color: var(--primary); }
.login-card .logo-area p { color: var(--gray-500); font-size: .9rem; margin-top: 4px; }

/* === CHAT VIEW === */
.chat-container { display: flex; gap: 0; height: calc(100vh - var(--topbar-height) - 64px); }
.chat-messages-panel { flex: 1; display: flex; flex-direction: column; }
.chat-messages-list { flex: 1; overflow-y: auto; padding: 24px; }

.chat-bubble { max-width: 75%; margin-bottom: 12px; }
.chat-bubble.user { margin-left: auto; }
.chat-bubble .bubble-content {
    padding: 12px 16px; border-radius: 16px;
    font-size: .9rem; line-height: 1.5;
}
.chat-bubble.assistant .bubble-content { background: var(--gray-100); color: var(--gray-800); border-bottom-left-radius: 4px; }
.chat-bubble.user .bubble-content { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble .bubble-meta { font-size: .72rem; color: var(--gray-400); margin-top: 4px; padding: 0 4px; }

.chat-info-panel {
    width: 320px; border-left: 1px solid var(--gray-200);
    padding: 24px; overflow-y: auto; background: #fff;
}

/* === UTILITY === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.font-mono { font-family: var(--font-mono); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.w-full { width: 100%; }
.hidden { display: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { font-family: var(--font-mono); font-size: .85rem; background: var(--gray-100); padding: 2px 6px; border-radius: 4px; }
