/* ============================================
   VoiceBot Admin Panel — Premium Dark Theme
   ============================================ */

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

/* === CSS Custom Properties === */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: rgba(22, 22, 50, 0.6);
    --bg-card-hover: rgba(30, 30, 65, 0.75);
    --bg-input: rgba(15, 15, 40, 0.8);
    --bg-sidebar: rgba(12, 12, 30, 0.95);
    --bg-modal: rgba(10, 10, 25, 0.95);

    --border-subtle: rgba(108, 99, 255, 0.15);
    --border-glow: rgba(108, 99, 255, 0.4);
    --border-accent: rgba(233, 69, 96, 0.4);

    --text-primary: #e8e8f0;
    --text-secondary: #8888a8;
    --text-muted: #555570;
    --text-accent: #6c63ff;

    --accent-primary: #6c63ff;
    --accent-secondary: #e94560;
    --accent-success: #00d68f;
    --accent-warning: #ffaa00;
    --accent-info: #00b4d8;

    --gradient-primary: linear-gradient(135deg, #6c63ff 0%, #e94560 100%);
    --gradient-card: linear-gradient(135deg, rgba(108, 99, 255, 0.08) 0%, rgba(233, 69, 96, 0.04) 100%);
    --gradient-sidebar: linear-gradient(180deg, #0a0a1a 0%, #111128 100%);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(108, 99, 255, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gradient-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    backdrop-filter: blur(20px);
    transition: width var(--transition-slow);
}

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
    min-height: var(--header-height);
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.sidebar-brand h1 {
    font-size: 1.15rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.sidebar-brand .brand-version {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--gradient-primary);
    border-radius: 0 3px 3px 0;
    transition: transform var(--transition-normal);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(108, 99, 255, 0.08);
}

.nav-item:hover::before {
    transform: translateY(-50%) scaleY(1);
}

.nav-item.active {
    color: var(--text-accent);
    background: rgba(108, 99, 255, 0.12);
}

.nav-item.active::before {
    transform: translateY(-50%) scaleY(1);
}

.nav-item .nav-icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent-primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.page-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(17, 17, 40, 0.5);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

.page-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-body {
    padding: 28px 32px;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    backdrop-filter: blur(12px);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* === Stat Cards (Dashboard) === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 22px;
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.stat-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card .stat-icon {
    font-size: 1.8rem;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card .stat-change {
    font-size: 0.72rem;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
}

.stat-change.up {
    color: var(--accent-success);
    background: rgba(0, 214, 143, 0.1);
}

.stat-change.down {
    color: var(--accent-secondary);
    background: rgba(233, 69, 96, 0.1);
}

/* Stat card color variants */
.stat-card.primary .stat-value {
    color: var(--accent-primary);
}

.stat-card.success .stat-value {
    color: var(--accent-success);
}

.stat-card.warning .stat-value {
    color: var(--accent-warning);
}

.stat-card.danger .stat-value {
    color: var(--accent-secondary);
}

.stat-card.info .stat-value {
    color: var(--accent-info);
}

/* === Tables === */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: rgba(108, 99, 255, 0.06);
}

th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(108, 99, 255, 0.06);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: rgba(108, 99, 255, 0.04);
}

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

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    outline: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 2px 12px rgba(108, 99, 255, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.45);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(108, 99, 255, 0.1);
    color: var(--accent-primary);
    border-color: rgba(108, 99, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(108, 99, 255, 0.18);
    border-color: rgba(108, 99, 255, 0.35);
}

.btn-danger {
    background: rgba(233, 69, 96, 0.1);
    color: var(--accent-secondary);
    border-color: rgba(233, 69, 96, 0.2);
}

.btn-danger:hover {
    background: rgba(233, 69, 96, 0.2);
    border-color: rgba(233, 69, 96, 0.4);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* === Forms === */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15), var(--shadow-glow);
}

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

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

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238888a8' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 0 1 .708 0L8 8.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-help {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success {
    background: rgba(0, 214, 143, 0.12);
    color: var(--accent-success);
}

.badge-danger {
    background: rgba(233, 69, 96, 0.12);
    color: var(--accent-secondary);
}

.badge-warning {
    background: rgba(255, 170, 0, 0.12);
    color: var(--accent-warning);
}

.badge-info {
    background: rgba(0, 180, 216, 0.12);
    color: var(--accent-info);
}

.badge-primary {
    background: rgba(108, 99, 255, 0.12);
    color: var(--accent-primary);
}

.badge-muted {
    background: rgba(85, 85, 112, 0.15);
    color: var(--text-secondary);
}

/* === Pulse animation for live badges === */
.badge-live {
    position: relative;
}

.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.4);
    }
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn var(--transition-normal);
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp var(--transition-slow);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

/* === Animations === */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-in {
    animation: slideIn var(--transition-normal);
}

/* === Transcript viewer === */
.transcript-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.transcript-msg {
    padding: 8px 14px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    animation: slideIn var(--transition-fast);
}

.transcript-msg.user {
    background: rgba(0, 180, 216, 0.1);
    border-left: 3px solid var(--accent-info);
}

.transcript-msg.agent {
    background: rgba(108, 99, 255, 0.1);
    border-left: 3px solid var(--accent-primary);
}

.transcript-msg .msg-role {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 3px;
}

.transcript-msg.user .msg-role {
    color: var(--accent-info);
}

.transcript-msg.agent .msg-role {
    color: var(--accent-primary);
}

.transcript-msg .msg-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    float: right;
}

/* === Empty state === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h4 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.85rem;
    max-width: 300px;
    margin: 0 auto 20px;
}

/* === Toast notifications === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    min-width: 280px;
    animation: slideIn var(--transition-normal);
}

.toast.success {
    border-left: 3px solid var(--accent-success);
}

.toast.error {
    border-left: 3px solid var(--accent-secondary);
}

.toast.warning {
    border-left: 3px solid var(--accent-warning);
}

/* === Status dot === */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--accent-success);
    box-shadow: 0 0 6px rgba(0, 214, 143, 0.5);
}

.status-dot.offline {
    background: var(--accent-secondary);
}

/* === Confirmation form inline === */
.confirm-delete {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* === HTMX loading indicator === */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(108, 99, 255, 0.4);
}

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

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

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

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .page-body {
        padding: 16px;
    }

    .page-header {
        padding: 16px;
    }
}

/* === Utility classes === */
.text-muted {
    color: var(--text-secondary);
}

.text-accent {
    color: var(--accent-primary);
}

.text-success {
    color: var(--accent-success);
}

.text-danger {
    color: var(--accent-secondary);
}

.text-warning {
    color: var(--accent-warning);
}

.text-sm {
    font-size: 0.8rem;
}

.text-xs {
    font-size: 0.7rem;
}

.text-mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.font-bold {
    font-weight: 700;
}

.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;
}

.gap-1 {
    gap: 8px;
}

.gap-2 {
    gap: 16px;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.w-full {
    width: 100%;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

/* === Login Page === */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: slideUp var(--transition-slow);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
}

.login-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

.login-form .form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-form .form-group input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    outline: none;
}

.login-form .form-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.login-form .form-group input::placeholder {
    color: var(--text-muted);
}

.btn-full {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
    margin-top: 8px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.alert-error {
    background: rgba(233, 69, 96, 0.12);
    color: var(--accent-secondary);
    border: 1px solid rgba(233, 69, 96, 0.25);
}

/* === Tenant Badge (sidebar) === */
.tenant-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    margin: 4px 12px;
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-primary);
}

.tenant-badge .tenant-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.tenant-badge .tenant-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Sidebar footer === */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-footer .logout-btn {
    color: var(--accent-secondary);
}

.sidebar-footer .logout-btn:hover {
    background: rgba(233, 69, 96, 0.1);
}

/* ═══════════════════════════════════════
   Agent Detail Page — V2
   ═══════════════════════════════════════ */

/* Agent Detail Header */
.agent-detail-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(17, 17, 40, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.agent-detail-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.agent-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-header-avatar {
    width: 38px;
    height: 38px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: var(--shadow-glow);
}

.agent-back-btn {
    font-size: 1.3rem;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toggle Switch */
.toggle-switch-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch.toggle-sm {
    width: 38px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(85, 85, 112, 0.4);
    border-radius: 24px;
    transition: all var(--transition-normal);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-normal);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.toggle-sm .toggle-slider::before {
    height: 14px;
    width: 14px;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--accent-success);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
}

.toggle-sm input:checked+.toggle-slider::before {
    transform: translateX(18px);
}

/* Tabs */
.agent-tabs {
    display: flex;
    gap: 0;
    padding: 0 32px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(17, 17, 40, 0.3);
    overflow-x: auto;
}

.tab-item {
    padding: 14px 20px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    white-space: nowrap;
}

.tab-item:hover {
    color: var(--text-primary);
    background: rgba(108, 99, 255, 0.04);
}

.tab-item.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 28px 32px;
    animation: fadeIn var(--transition-normal);
}

.tab-content.active {
    display: block;
}

/* === Overview Grid V2 (3-column) === */
.overview-grid-v2 {
    display: grid;
    grid-template-columns: 1fr 0.8fr 1.2fr;
    gap: 20px;
    align-items: start;
}

.overview-col-left,
.overview-col-center,
.overview-col-right {
    display: flex;
    flex-direction: column;
}

/* Legacy 1-col grid */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    backdrop-filter: blur(12px);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.overview-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.overview-card-wide {
    grid-column: span 2;
}

.overview-card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.overview-card-header h4 {
    font-size: 0.92rem;
    font-weight: 600;
}

.overview-card-body {
    padding: 18px;
}

/* Agent Info Row */
.agent-info-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.agent-avatar-lg {
    width: 52px;
    height: 52px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.agent-role-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 2px;
}

/* Agent Meta V2 */
.agent-meta-v2 {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-label-v2 {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.meta-value-v2 {
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Agent Type Badge */
.badge-agent-type {
    background: rgba(255, 170, 0, 0.12);
    color: var(--accent-warning);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid rgba(255, 170, 0, 0.25);
}

/* === Stat Pills === */
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    min-width: 120px;
}

.stat-pill-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-pill-label {
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.3;
}

.stat-pill-primary {
    background: rgba(108, 99, 255, 0.1);
    border: 1px solid rgba(108, 99, 255, 0.2);
}

.stat-pill-primary .stat-pill-value {
    color: var(--accent-primary);
}

.stat-pill-primary .stat-pill-label {
    color: var(--accent-primary);
}

.stat-pill-success {
    background: rgba(0, 214, 143, 0.1);
    border: 1px solid rgba(0, 214, 143, 0.2);
}

.stat-pill-success .stat-pill-value {
    color: var(--accent-success);
}

.stat-pill-success .stat-pill-label {
    color: var(--accent-success);
}

.stat-pill-muted {
    background: rgba(85, 85, 112, 0.1);
    border: 1px solid rgba(85, 85, 112, 0.2);
}

.stat-pill-muted .stat-pill-value {
    color: var(--text-secondary);
}

.stat-pill-muted .stat-pill-label {
    color: var(--text-secondary);
}

.stat-pill-accent {
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-pill-accent .stat-pill-value {
    color: #fff;
    font-size: 1.1rem;
}

/* === Contactos === */
.contactos-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.contactos-avatars {
    display: flex;
    gap: 0;
}

.contact-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gradient-card);
    border: 2px solid var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-left: -8px;
    position: relative;
    transition: transform var(--transition-fast);
}

.contact-avatar:first-child {
    margin-left: 0;
}

.contact-avatar:hover {
    transform: translateY(-3px);
    z-index: 2;
}

/* === Greeting Preview V2 === */
.greeting-preview-v2 {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: rgba(108, 99, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    line-height: 1.6;
}

.greeting-preview-v2 .greeting-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* === Conocimiento List === */
.conocimiento-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conocimiento-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(108, 99, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-size: 0.82rem;
    transition: all var(--transition-fast);
}

.conocimiento-item:hover {
    border-color: var(--border-glow);
    background: rgba(108, 99, 255, 0.08);
}

.conocimiento-item .doc-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.conocimiento-item .doc-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Herramientas List === */
.herramientas-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.herramienta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(108, 99, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition-fast);
}

.herramienta-item:hover {
    border-color: var(--border-glow);
    background: rgba(108, 99, 255, 0.08);
}

.herramienta-item .tool-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.herramienta-item .tool-info {
    flex: 1;
}

.herramienta-item .tool-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.herramienta-item .tool-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* === Danger Zone Card === */
.card-danger {
    border-color: rgba(233, 69, 96, 0.25);
}

.card-danger:hover {
    border-color: rgba(233, 69, 96, 0.4);
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.1);
}

/* Prompt Preview */
.prompt-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
    max-height: 180px;
    overflow: hidden;
    position: relative;
    white-space: pre-wrap;
    word-break: break-word;
}

.prompt-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(transparent, var(--bg-card));
    pointer-events: none;
}

/* Config List */
.config-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.config-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(108, 99, 255, 0.06);
}

.config-item:last-child {
    border-bottom: none;
}

.config-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.config-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Stat Mini */
.stat-mini {
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    text-align: center;
    min-width: 130px;
}

.stat-mini.primary .stat-mini-value {
    color: var(--accent-primary);
}

.stat-mini-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-mini-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Rule Chip */
.rule-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(108, 99, 255, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    font-size: 0.78rem;
    margin: 3px 4px 3px 0;
}

.rule-intent {
    font-weight: 600;
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 1100px) {
    .overview-grid-v2 {
        grid-template-columns: 1fr 1fr;
    }

    .overview-col-right {
        grid-column: span 2;
    }
}

@media (max-width: 900px) {
    .overview-grid-v2 {
        grid-template-columns: 1fr;
    }

    .overview-col-right {
        grid-column: span 1;
    }

    .overview-grid {
        grid-template-columns: 1fr;
    }

    .overview-card-wide {
        grid-column: span 1;
    }

    .agent-detail-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .agent-tabs {
        padding: 0 16px;
    }

    .tab-content {
        padding: 16px;
    }
}