@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;0,9..144,700&family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;800&display=swap');

:root {
    --bg-base: #f5f2eb;
    --bg-surface: #ffffff;
    --bg-surface-solid: #faf8f4;
    --bg-surface-hover: #ede9e1;
    --border-color: #e8e3d9;
    
    --primary: #2f4f2f;
    --primary-hover: #3a5f3a;
    --secondary: #2f4f2f;
    --accent-gradient: linear-gradient(135deg, #2f4f2f, #7a6030);
    
    --text-main: #2b2b2b;
    --text-muted: #6b6b6b;

    --font-heading: 'Fraunces', 'Playfair Display', Georgia, serif;
    --font-body: 'DM Sans', 'Inter', system-ui, sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 22px;
    
    --shadow-glow: 0 0 20px rgba(47, 79, 47, 0.18);
    --shadow-card: 0 14px 40px rgba(64, 55, 42, 0.07);
}

/* Base Reset & Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background:
        radial-gradient(circle at 12% 8%, rgba(223, 232, 220, 0.64), transparent 25rem),
        var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.2;
}

a {
    color: var(--text-main);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover {
    color: var(--secondary);
}

/* Layout Utilities */
.container {
    width: min(1200px, 92%);
    margin: 0 auto;
}

/* Glassmorphism Classes */
.glass-panel {
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: 14px;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 79, 47, 0.12);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-body);
    font-weight: 800;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #ffffff;
    border-color: rgba(47, 79, 47, 0.25);
    color: var(--primary);
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-block { display: block; width: 100%; }

/* Navigation */
.navbar {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.navbar-brand {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.navbar-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* UI Structure */
.layout {
    display: flex;
    min-height: calc(100vh - 80px); /* minus navbar */
}
.sidebar {
    width: 260px;
    background: var(--bg-surface-solid);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    font-weight: 500;
}
.sidebar-link:hover, .sidebar-link.active {
    background: rgba(194, 65, 12, 0.1);
    color: var(--primary);
}
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* App shell: dashboard + configuración de cuenta (no builder) */
.app-dashboard-layout {
    display: flex;
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 10%, rgba(223, 232, 220, 0.7), transparent 25rem),
        linear-gradient(180deg, #f5f2eb 0%, #ede9e1 100%);
}
.app-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.72);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    backdrop-filter: blur(16px);
}
.app-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}
.app-sidebar-brand img {
    display: block;
    width: min(170px, 100%);
    height: auto;
}
.app-sidebar-nav {
    flex: 1;
}
.app-sidebar-nav .nav-item,
.app-sidebar-nav a.nav-item {
    display: block;
    padding: 0.85rem 1.25rem;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    margin-bottom: 0.65rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
}

.app-sidebar-nav .nav-item:hover,
.app-sidebar-nav .nav-item.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: var(--shadow-card);
    border-color: var(--border-color);
}

.app-sidebar-nav a.app-sidebar-nav-external {
    color: var(--text-muted);
}
.app-sidebar-footer {
    margin-top: auto;
}
.app-main-content {
    flex: 1;
    min-width: 0;
    padding: 2.5rem;
    overflow-y: auto;
    color: var(--text-main);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.34)),
        transparent;
    box-shadow: inset 1px 0 0 rgba(232, 227, 217, 0.72);
}
.app-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.app-section-header h1,
.app-section-header h2 {
    margin: 0;
    font-size: clamp(1.7rem, 3vw, 2.35rem);
    letter-spacing: -0.035em;
}
.tab-section {
    display: none;
}
.tab-section.active {
    display: block;
    animation: appTabFadeIn 0.3s ease;
}

@media (max-width: 760px) {
    .app-dashboard-layout {
        display: block;
    }

    .app-sidebar {
        width: 100%;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .app-sidebar-brand {
        margin-bottom: 1rem;
    }

    .app-sidebar-brand img {
        width: 150px;
    }

    .app-sidebar-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .app-sidebar-nav .nav-item,
    .app-sidebar-nav a.nav-item {
        margin: 0;
        text-align: center;
        padding: 0.75rem 0.85rem;
    }

    .app-main-content {
        padding: 1.25rem;
    }
}
@keyframes appTabFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards & Lists */
.card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.bot-card {
    padding: 1.5rem;
    transition: transform 0.3s;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
}
.bot-card:hover {
    transform: translateY(-5px);
}
.bot-card--active {
    border-color: rgba(34, 139, 34, 0.35);
    box-shadow: 0 10px 30px rgba(34, 139, 34, 0.12);
}
.bot-card--inactive {
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(255, 255, 255, 0.78);
}
.bot-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}
.bot-card-name {
    flex: 1;
    min-width: 0;
    margin-right: 0.75rem;
}
.bot-card-name-text {
    cursor: pointer;
    border-radius: var(--radius-sm, 0.35rem);
    padding: 0.1rem 0.25rem;
    margin: -0.1rem -0.25rem;
    display: inline-block;
    max-width: 100%;
}
.bot-card-name-text:hover {
    background: rgba(47, 79, 47, 0.08);
}
.bot-card-name-input {
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm, 0.35rem);
    border: 1px solid rgba(47, 79, 47, 0.45);
    background: #ffffff;
    color: inherit;
}
.bot-card-name-input:focus {
    outline: none;
    border-color: rgba(47, 79, 47, 0.85);
    box-shadow: 0 0 0 3px rgba(47, 79, 47, 0.12);
}
.status-badge {
    display: inline-block;
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
    border-radius: 9999px;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.status-badge--active {
    background: rgba(22, 163, 74, 0.14);
    color: #166534;
}
.status-badge--inactive {
    background: rgba(239, 68, 68, 0.14);
    color: #991b1b;
}
.bot-card-state {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
}
.bot-card-version-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}
.bot-card-version-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
}
.bot-card-status-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
}
.bot-card-metrics {
    margin-top: 0.72rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.62rem;
    background: rgba(255, 255, 255, 0.84);
}
.bot-card-metrics-title {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.01em;
    margin-bottom: 0.42rem;
}
.bot-card-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
}
.bot-card-metric-item {
    border: 1px solid rgba(47, 79, 47, 0.16);
    border-radius: 10px;
    padding: 0.35rem 0.42rem;
    background: rgba(223, 232, 220, 0.34);
}
.bot-card-metric-label {
    display: block;
    font-size: 0.66rem;
    color: var(--text-muted);
    line-height: 1.2;
}
.bot-card-metric-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}
.bot-card-conv-note {
    margin-top: 0.6rem;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.chatbot-conv-day {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 0.7rem;
    background: rgba(255, 255, 255, 0.74);
}
.chatbot-conv-day > summary {
    padding: 0.62rem 0.72rem;
    cursor: pointer;
    font-weight: 700;
    color: #334155;
    list-style: none;
}
.chatbot-conv-day > summary::-webkit-details-marker {
    display: none;
}
.chatbot-conv-day > summary::before {
    content: '▸';
    margin-right: 0.42rem;
    color: var(--text-muted);
}
.chatbot-conv-day[open] > summary::before {
    content: '▾';
}
.chatbot-conv-items {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0 0.55rem 0.62rem;
}
.chatbot-conv-item {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
}
.chatbot-conv-item > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.55rem 0.62rem;
}
.chatbot-conv-item-head {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
}
.chatbot-conv-item-check {
    margin-top: 0.08rem;
    width: 15px;
    height: 15px;
    cursor: pointer;
    flex-shrink: 0;
}
.chatbot-conv-item-main {
    min-width: 0;
    flex: 1;
}
.chatbot-conv-item > summary::-webkit-details-marker {
    display: none;
}
.chatbot-conv-item-line {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.chatbot-conv-item-meta {
    font-size: 0.73rem;
    color: var(--text-muted);
}
.chatbot-conv-thread {
    border-top: 1px solid var(--border-color);
    padding: 0.55rem 0.62rem 0.62rem;
}
.chatbot-conv-bubble {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.42rem 0.52rem;
    margin-bottom: 0.4rem;
    font-size: 0.78rem;
    line-height: 1.45;
    background: #fff;
}
.chatbot-conv-bubble-user {
    border-color: rgba(47, 79, 47, 0.22);
    background: rgba(223, 232, 220, 0.35);
}
.chatbot-conv-bubble-assistant {
    border-color: rgba(51, 65, 85, 0.2);
    background: rgba(241, 245, 249, 0.6);
}
.bot-status-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    user-select: none;
}
.bot-status-switch.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.bot-status-switch input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}
.bot-status-switch-track {
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    transition: background-color 0.2s ease;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.14);
}
.bot-status-switch-track::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
    transition: transform 0.2s ease;
}
.bot-status-switch input:checked + .bot-status-switch-track {
    background: #2f7a40;
}
.bot-status-switch input:checked + .bot-status-switch-track::after {
    transform: translateX(20px);
}

/* Split Builder Pane */
.split-pane {
    display: flex;
    gap: 1.5rem;
    height: calc(100vh - 120px);
}
.pane {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}
.pane-sidebar {
    flex: 0 0 350px;
}

/* Utils */
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-4 { margin-top: 2rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 0.5rem; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: var(--radius-sm, 0.5rem);
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.icon-btn:hover {
    color: var(--text-main);
    border-color: rgba(47, 79, 47, 0.35);
    background: rgba(47, 79, 47, 0.1);
}
.icon-btn-danger:hover {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.1);
}
.icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Landing Section */
.hero-section {
    padding: 8rem 0 6rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero-bg-glow {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.2) 0%, transparent 70%);
    z-index: -1;
    border-radius: 50%;
}
.hero-title {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}
.hero-title span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2.5rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(28, 25, 23, 0.5);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-surface);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 600px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.close-modal {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    line-height: 1;
}

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

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th, .table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-family: var(--font-body);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
}

.table tbody tr:hover {
    background: rgba(0, 0, 0, 0.01);
}

/* Layout helpers */
.card-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .card-list {
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    }
}

@media (max-width: 720px) {
    .bot-card-metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Forms refinement */
input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    cursor: pointer;
    accent-color: var(--primary);
    vertical-align: middle;
}

.form-group label {
    margin-bottom: 0.4rem;
    display: block;
}

/* Custom Pre */
pre {
    background: #1c1917;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    color: #f5f3ef;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    font-size: 0.85rem;
    margin-top: 1rem;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
}
