/* ============================================================
   Student Services Bot — Admin Panel Styles
   Matches ES Dubai portal design: Poppins, #F48220 primary
   ============================================================ */

:root {
    --primary: #F48220;
    --primary-light: rgba(244, 130, 32, 0.08);
    --primary-hover: #e0741a;
    --dark: #303335;
    --text: #1A1A1A;
    --text-muted: #989898;
    --bg: #f4f5f7;
    --white: #ffffff;
    --border: #e8e8e8;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --sidebar-w: 240px;
    --sidebar-collapsed: 60px;
    --topbar-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Poppins', system-ui, sans-serif; color: var(--text); background: var(--bg); }

/* ---- Admin Layout ---- */
.admin-layout { display: flex; height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w); background: var(--dark); color: #fff;
    display: flex; flex-direction: column; flex-shrink: 0;
    transition: width 0.3s; overflow: hidden; z-index: 100;
}
.sidebar-brand {
    padding: 18px 20px; display: flex; align-items: center; gap: 12px;
    font-size: 17px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand i { font-size: 22px; color: var(--primary); }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 14px; padding: 11px 20px;
    color: rgba(255,255,255,0.6); text-decoration: none; font-size: 13px;
    font-weight: 500; transition: all 0.2s; border-left: 3px solid transparent;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-item.active { color: #fff; background: rgba(244,130,32,0.15); border-left-color: var(--primary); }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding: 8px 0; }

/* ---- Main Content ---- */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
    padding: 0 24px; background: var(--white); border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-toggle { background: none; border: none; font-size: 18px; color: var(--text-muted); cursor: pointer; display: none; }
.page-title { font-size: 18px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-user { font-size: 13px; color: var(--text-muted); }
.admin-user i { margin-right: 4px; }

/* ---- Content Area ---- */
.content-area { flex: 1; overflow-y: auto; padding: 24px; }

/* ---- Cards ---- */
.card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--border); overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-header h3 i { color: var(--primary); font-size: 14px; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: #fafafa; }

/* ---- Stats Grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--white); border-radius: var(--radius); padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
}
.stat-card-sm { flex-direction: column; text-align: center; gap: 4px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--dark); line-height: 1.2; }
.stat-card-sm .stat-value { font-size: 28px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ---- Dashboard Grid ---- */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* ---- Data Tables ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
.data-table tr:hover td { background: #fafafa; }
.data-table tr:last-child td { border-bottom: none; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-active { background: rgba(46,204,113,0.1); color: var(--success); }
.badge-resolved, .badge-ticket_created { background: rgba(52,152,219,0.1); color: var(--info); }
.badge-abandoned { background: rgba(231,76,60,0.1); color: var(--danger); }
.badge-ticket { background: var(--primary-light); color: var(--primary); }

/* ---- Bar Chart ---- */
.bar-item { margin-bottom: 14px; }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar-track { height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.5s; }

/* ---- Buttons ---- */
.btn-primary {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius-sm); font-family: inherit;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: 0.2s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; background: var(--white); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: 0.2s;
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 8px 16px; border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; cursor: pointer; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-link { color: var(--primary); text-decoration: none; font-size: 13px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.btn-group { display: flex; gap: 8px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-group label i { margin-right: 4px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
    color: var(--text); background: var(--white); outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { min-height: 120px; resize: vertical; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.alert-danger { background: rgba(231,76,60,0.1); color: var(--danger); border: 1px solid rgba(231,76,60,0.2); }
.alert-success { background: rgba(46,204,113,0.1); color: var(--success); border: 1px solid rgba(46,204,113,0.2); }
.alert-info { background: rgba(52,152,219,0.1); color: var(--info); border: 1px solid rgba(52,152,219,0.2); }

/* ---- Empty State ---- */
.empty-state { text-align: center; color: var(--text-muted); padding: 30px; font-size: 14px; }

/* ---- Utilities ---- */
.fw-500 { font-weight: 500; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.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; } .flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }

/* ---- Login Page ---- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, var(--dark) 0%, #1a1a2e 100%);
}
.login-card {
    width: 400px; background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow-md); overflow: hidden;
}
.login-header {
    text-align: center; padding: 30px 20px 20px; background: var(--primary-light);
    border-bottom: 1px solid var(--border);
}
.login-header i { font-size: 40px; color: var(--primary); margin-bottom: 10px; display: block; }
.login-header h1 { font-size: 22px; font-weight: 700; color: var(--dark); }
.login-header p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-form { padding: 24px; }

/* ---- Knowledge Base ---- */
.upload-zone {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px;
    text-align: center; color: var(--text-muted); cursor: pointer; transition: all 0.2s;
    margin-bottom: 20px;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.upload-zone i { font-size: 36px; margin-bottom: 10px; display: block; }
.upload-zone p { font-size: 14px; }

.doc-list { list-style: none; }
.doc-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid #f0f0f0; transition: background 0.2s;
}
.doc-item:hover { background: #fafafa; }
.doc-item:last-child { border-bottom: none; }
.doc-info { flex: 1; }
.doc-title { font-weight: 600; font-size: 14px; }
.doc-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.doc-actions { display: flex; gap: 8px; }

/* ---- Prompt Studio ---- */
.prompt-editor-container { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
.prompt-editor textarea { font-family: 'Courier New', monospace; font-size: 13px; min-height: 400px; line-height: 1.6; }
.variable-list { list-style: none; }
.variable-item {
    padding: 6px 10px; font-size: 12px; color: var(--primary); cursor: pointer;
    border-radius: var(--radius-sm); font-family: monospace; transition: background 0.2s;
}
.variable-item:hover { background: var(--primary-light); }

/* ---- Conversation Detail ---- */
.chat-transcript { max-width: 700px; }
.transcript-msg { margin-bottom: 12px; display: flex; flex-direction: column; }
.transcript-msg.student { align-items: flex-end; }
.transcript-msg.assistant { align-items: flex-start; }
.transcript-bubble {
    max-width: 80%; padding: 10px 14px; border-radius: 12px;
    font-size: 13px; line-height: 1.5; position: relative;
}
.transcript-msg.student .transcript-bubble { background: var(--primary-light); border: 1px solid rgba(244,130,32,0.2); }
.transcript-msg.assistant .transcript-bubble { background: var(--white); border: 1px solid var(--border); box-shadow: var(--shadow); }
.transcript-time { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.transcript-meta { font-size: 10px; color: var(--text-muted); display: flex; gap: 10px; margin-top: 2px; }
.flag-btn { font-size: 11px; color: var(--text-muted); cursor: pointer; border: none; background: none; }
.flag-btn:hover { color: var(--danger); }
.flag-btn.flagged { color: var(--danger); }

/* ---- AI Settings ---- */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.provider-card {
    background: var(--white); border: 2px solid var(--border); border-radius: var(--radius);
    padding: 20px; text-align: center; transition: all 0.2s; cursor: pointer;
}
.provider-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.provider-card.active { border-color: var(--primary); background: var(--primary-light); }
.provider-card .provider-name { font-size: 16px; font-weight: 700; margin: 10px 0 4px; }
.provider-card .provider-status { font-size: 12px; color: var(--text-muted); }
.provider-card .provider-status.connected { color: var(--success); }
.provider-card i.provider-icon { font-size: 32px; color: var(--dark); }

.slider-container { display: flex; align-items: center; gap: 12px; }
.slider-container input[type="range"] { flex: 1; accent-color: var(--primary); }
.slider-value { font-weight: 600; font-size: 14px; min-width: 30px; }

/* ---- Search Test ---- */
.search-test { display: flex; gap: 10px; margin-bottom: 20px; }
.search-test input { flex: 1; }
.search-results .result-item { padding: 12px; margin-bottom: 8px; background: #fafafa; border-radius: var(--radius-sm); border-left: 3px solid var(--primary); }
.result-item .result-source { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.result-item .result-content { font-size: 13px; margin-top: 4px; }
.result-item .result-score { font-size: 11px; color: var(--primary); font-weight: 600; }

/* ---- Tabs ---- */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 20px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; background: none; border-top: none; border-left: none; border-right: none; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; display: none; }
.modal-overlay.active { display: flex; }
.modal { background: var(--white); border-radius: var(--radius); width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Responsive ---- */
@media (max-width: 992px) {
    .sidebar { position: fixed; left: -var(--sidebar-w); z-index: 200; height: 100vh; }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: block; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .prompt-editor-container { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .content-area { padding: 16px; }
}
