/* ===== Sovran AI Portal - Styles ===== */
:root {
    --gold: #C9A96E;
    --gold-light: #dbc087;
    --gold-dark: #ab8d60;
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-sidebar: #0d0d14;
    --bg-input: #1a1a25;
    --text: #e8e8ed;
    --text-muted: #8888a0;
    --border: #2a2a3a;
    --danger: #e74c3c;
    --success: #2ecc71;
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ===== AUTH ===== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0a0f 0%, #141420 50%, #0a0a0f 100%);
}

.auth-container { width: 100%; max-width: 420px; padding: 20px; }

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
}

.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 { font-size: 28px; color: var(--gold); margin-top: 12px; font-weight: 700; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.logo-icon { display: flex; justify-content: center; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--gold);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primary { background: linear-gradient(135deg, var(--gold-dark), var(--gold-light)); color: #111; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.auth-switch a { color: var(--gold); text-decoration: none; }
.error-msg { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; padding: 8px; background: rgba(231,76,60,0.1); border-radius: var(--radius-sm); }

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

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.logo-small { display: flex; align-items: center; gap: 10px; }
.logo-small span { font-size: 18px; font-weight: 700; color: var(--gold); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active { color: var(--gold); border-left-color: var(--gold); background: rgba(201,169,110,0.05); }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold-light));
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; color: #111;
}
.user-details { display: flex; flex-direction: column; }
.user-details span:first-child { font-size: 13px; font-weight: 500; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.btn-logout {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
    width: 100%; transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

.main-content { flex: 1; margin-left: 260px; padding: 32px; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 24px; font-weight: 600; }

/* ===== AGENTS GRID ===== */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
    display: block;
}
.agent-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }

.agent-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.agent-icon { font-size: 32px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 12px; }
.agent-card-header h3 { font-size: 16px; font-weight: 600; }
.agent-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.agent-caps { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.cap-tag {
    font-size: 11px; padding: 3px 8px; background: rgba(201,169,110,0.1);
    color: var(--gold); border-radius: 20px; border: 1px solid rgba(201,169,110,0.2);
}

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

.chat-sidebar {
    width: 280px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
}
.chat-sidebar-header { padding: 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.back-btn { color: var(--text-muted); text-decoration: none; font-size: 14px; }
.back-btn:hover { color: var(--gold); }

.chat-history { flex: 1; overflow-y: auto; padding: 8px; }
.chat-history-item {
    padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 13px; color: var(--text-muted); margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-history-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.chat-history-item.active { background: rgba(201,169,110,0.1); color: var(--gold); }

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.chat-agent-info { display: flex; align-items: center; gap: 12px; }
.agent-icon-lg { font-size: 28px; }
.chat-agent-info h3 { font-size: 16px; font-weight: 600; }

.chat-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.welcome-msg { text-align: center; margin: auto; padding: 40px; }
.welcome-icon { font-size: 48px; display: block; margin-bottom: 16px; }
.welcome-msg h3 { font-size: 20px; margin-bottom: 8px; }

.message { display: flex; gap: 12px; max-width: 80%; animation: fadeIn 0.3s ease; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.assistant { align-self: flex-start; }

.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.message.user .msg-avatar { background: linear-gradient(135deg, var(--gold-dark), var(--gold-light)); color: #111; }
.message.assistant .msg-avatar { background: var(--bg-input); }

.msg-bubble {
    padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
}
.message.user .msg-bubble { background: linear-gradient(135deg, var(--gold-dark), var(--gold-light)); color: #111; border-bottom-right-radius: 4px; }
.message.assistant .msg-bubble { background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.chat-input-area { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg-dark); }
.chat-input-wrapper { display: flex; align-items: flex-end; gap: 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
.chat-input-wrapper:focus-within { border-color: var(--gold); }

#chat-input {
    flex: 1; background: transparent; border: none; color: var(--text);
    font-size: 14px; font-family: inherit; resize: none; outline: none;
    max-height: 120px; line-height: 1.5;
}

.btn-send {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold-light));
    border: none; border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #111; flex-shrink: 0;
    transition: opacity 0.2s;
}
.btn-send:hover { opacity: 0.8; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== CONVERSATIONS LIST ===== */
.conversations-list { display: flex; flex-direction: column; gap: 8px; }
.conv-item {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: all 0.2s; text-decoration: none; color: var(--text);
}
.conv-item:hover { border-color: var(--gold); }
.conv-icon { font-size: 24px; }
.conv-info { flex: 1; }
.conv-info h4 { font-size: 14px; font-weight: 500; }
.conv-info p { font-size: 12px; color: var(--text-muted); }
.conv-time { font-size: 11px; color: var(--text-muted); }

/* ===== SERVICES ===== */
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.service-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; text-align: center;
}
.service-icon { font-size: 36px; margin-bottom: 12px; }
.service-card h3 { font-size: 16px; margin-bottom: 4px; }
.service-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

/* ===== ADMIN ===== */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 24px; }
.tab {
    padding: 8px 20px; background: transparent; border: 1px solid var(--border);
    color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer;
    font-size: 14px; font-family: inherit; transition: all 0.2s;
}
.tab.active { background: rgba(201,169,110,0.1); color: var(--gold); border-color: var(--gold); }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.admin-item-info { display: flex; align-items: center; gap: 12px; }
.admin-item-info .icon { font-size: 24px; }
.admin-item-info h4 { font-size: 14px; }
.admin-item-info p { font-size: 12px; color: var(--text-muted); }

/* ===== MODAL ===== */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
}
.modal-content {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 32px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; }

.loading-state { text-align: center; padding: 40px; color: var(--text-muted); }

.admin-only { display: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .logo-small span,
    .sidebar .nav-item span:not(.nav-icon),
    .sidebar .user-details,
    .sidebar .btn-logout { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .main-content { margin-left: 60px; padding: 16px; }
    .chat-sidebar { width: 0; display: none; }
    .agents-grid { grid-template-columns: 1fr; }
}
