/* Reset & General Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0d120f;
    --bg-panel: rgba(22, 31, 25, 0.7);
    --border-color: rgba(255, 255, 255, 0.07);
    --text-primary: #f0f4f1;
    --text-secondary: #a3b3a7;
    --primary-color: #2e7d32;
    --primary-light: #4caf50;
    --accent-gold: #c5a059;
    --accent-gold-hover: #b08d4b;
    --error-red: #d32f2f;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
    background: radial-gradient(circle at top left, #1b2e21 0%, #0d120f 60%);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background: rgba(13, 18, 15, 0.85);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.brand-emoji {
    font-size: 28px;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.brand-text p {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-gold);
    font-weight: 600;
}

/* Motto Box */
.motto-box {
    background: rgba(197, 160, 89, 0.08);
    border: 1px solid rgba(197, 160, 89, 0.25);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 32px;
}

.motto-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-gold);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.motto-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.motto-desc strong {
    color: var(--text-primary);
}

/* Agent Nav */
.agent-nav {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 12px;
}

.agent-nav ul {
    list-style: none;
}

.agent-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.agent-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.agent-item.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
}

.agent-item-number {
    font-size: 11px;
    opacity: 0.6;
    font-weight: 600;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.erp-status {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--primary-light);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--primary-light);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    max-height: 100vh;
}

/* Main Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
}

.welcome-text h2 {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.welcome-text p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Live Stats */
.stats-container {
    display: flex;
    gap: 16px;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 180px;
    backdrop-filter: blur(16px);
}

.stat-icon {
    font-size: 24px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-gold);
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1px;
}

.tab-btn {
    background: none;
    border: none;
    outline: none;
    padding: 12px 24px;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}

/* Panels */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

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

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

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(16px);
}

.full-width-panel {
    width: 100%;
}

.panel h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.panel-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Playground Layout */
.playground-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.form-group textarea {
    width: 100%;
    height: 240px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: var(--transition-smooth);
}

.form-group textarea:focus {
    border-color: var(--accent-gold);
    background: rgba(0, 0, 0, 0.4);
}

/* Output Area */
.output-container {
    position: relative;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    height: 240px;
    overflow-y: auto;
    padding: 16px;
}

.output-container pre {
    color: var(--text-primary);
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.output-container pre.placeholder-text {
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.6;
}

/* Loader Overlay */
.loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 18, 15, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    border-radius: 12px;
    z-index: 10;
}

.loader-overlay.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(197, 160, 89, 0.1);
    border-top: 3px solid var(--accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Actions Row */
.actions-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.actions-row.right {
    justify-content: flex-end;
}

/* Buttons */
.btn {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--accent-gold);
    color: #0d120f;
}

.btn-primary:hover {
    background: var(--accent-gold-hover);
    box-shadow: 0 4px 12px rgba(197, 160, 89, 0.25);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Ficha Grid */
.ficha-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 24px;
    margin-top: 12px;
}

.ficha-card {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.ficha-card h4 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-gold);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ficha-card p {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
}

.ficha-card ul {
    list-style: none;
}

.ficha-card li {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 14px;
    position: relative;
}

.ficha-card li::before {
    content: "•";
    color: var(--accent-gold);
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* Prompt Editor */
.prompt-editor-container textarea {
    width: 100%;
    height: 400px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    color: var(--text-primary);
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: var(--transition-smooth);
}

.prompt-editor-container textarea:focus {
    border-color: var(--accent-gold);
    background: rgba(0, 0, 0, 0.4);
}

.save-status {
    font-size: 12px;
    align-self: center;
    color: var(--primary-light);
    margin-left: 12px;
    animation: pulse 1.5s infinite;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .playground-layout {
        grid-template-columns: 1fr;
    }
    .ficha-grid {
        grid-template-columns: 1fr;
    }
}

/* Login Screen styles */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1b2e21 0%, #080d0a 80%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.login-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.login-card {
    background: rgba(22, 31, 25, 0.75);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    padding: 40px;
    width: 380px;
    text-align: center;
    backdrop-filter: blur(20px);
    animation: scaleIn 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.login-logo {
    font-size: 48px;
    margin-bottom: 16px;
    display: inline-block;
    filter: drop-shadow(0 0 10px rgba(46, 125, 50, 0.3));
}

.login-card h2 {
    font-family: var(--font-heading);
    font-size: 24px;
    margin-bottom: 6px;
}

.login-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.form-group-login {
    margin-bottom: 20px;
}

.form-group-login input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    padding: 14px 18px;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    text-align: center;
    transition: var(--transition-smooth);
}

.form-group-login input:focus {
    border-color: var(--accent-gold);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 10px rgba(197, 160, 89, 0.15);
}

.btn.full-width {
    width: 100%;
    padding: 14px;
    font-size: 14px;
}

.login-error {
    margin-top: 16px;
    font-size: 12px;
    color: #ff5252;
}

.login-error.hidden {
    display: none;
}

/* --- Estilos Multi-rol e Inventario --- */

/* Alerta de Logística */
.alert-banner {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.4s ease;
}

.alert-ping {
    width: 10px;
    height: 10px;
    background-color: #f59e0b;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.alert-ping::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f59e0b;
    border-radius: 50%;
    animation: ping 1.5s infinite;
}

@keyframes ping {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(3); opacity: 0; }
}

.alert-content {
    font-size: 13px;
    color: #fce7cf;
    line-height: 1.4;
}

.alert-content strong {
    color: #f59e0b;
    font-weight: 600;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 6px;
}

/* Tabla de Inventario */
.table-responsive {
    overflow-x: auto;
    margin-top: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

.inventory-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.inventory-table th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--accent-gold);
    font-family: var(--font-heading);
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.inventory-table td {
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    vertical-align: middle;
}

.inventory-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Inputs de la Tabla (Logística) */
.inventory-table input[type="number"],
.inventory-table input[type="date"] {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    width: 100%;
    outline: none;
    transition: var(--transition-smooth);
}

.inventory-table input[type="number"]:focus,
.inventory-table input[type="date"]:focus {
    border-color: var(--accent-gold);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 8px rgba(197, 160, 89, 0.15);
}

/* Inputs deshabilitados (Lectura para Comercial/Marketing) */
.inventory-table input:disabled {
    background: transparent !important;
    border-color: transparent !important;
    color: var(--text-primary) !important;
    padding: 8px 0;
    cursor: default;
}

/* Badges de Estado */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-green {
    background: rgba(46, 125, 50, 0.15);
    color: #81c784;
    border: 1px solid rgba(46, 125, 50, 0.3);
}

.badge-yellow {
    background: rgba(251, 192, 45, 0.12);
    color: #fff176;
    border: 1px solid rgba(251, 192, 45, 0.3);
}

.badge-red {
    background: rgba(211, 47, 47, 0.15);
    color: #e57373;
    border: 1px solid rgba(211, 47, 47, 0.3);
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(211, 47, 47, 0); }
    100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0); }
}

/* Layout de Paneles de Logística */
.logistics-panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

.logistics-panel.active {
    display: block;
}

.panel-header-row {
    margin-bottom: 20px;
}

/* --- KPI Grid & Cards (Dashboard) --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.kpi-card.highlight {
    background: rgba(211, 47, 47, 0.05);
    border-color: rgba(211, 47, 47, 0.2);
}

.kpi-card.highlight:hover {
    border-color: rgba(211, 47, 47, 0.4);
    box-shadow: 0 8px 30px rgba(211, 47, 47, 0.1);
}

.kpi-icon {
    font-size: 28px;
    background: rgba(255, 255, 255, 0.03);
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.kpi-card.highlight .kpi-icon {
    background: rgba(211, 47, 47, 0.1);
    border-color: rgba(211, 47, 47, 0.2);
}

.kpi-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-value {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-card.highlight .kpi-value {
    color: #e57373;
}

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Dashboard Columns */
.dashboard-columns {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    margin-top: 24px;
}

@media (max-width: 1024px) {
    .dashboard-columns {
        grid-template-columns: 1fr;
    }
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #757575;
}

.status-dot.green {
    background: #2e7d32;
    box-shadow: 0 0 8px rgba(46, 125, 50, 0.5);
}

.status-dot.orange {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.status-dot.pulse {
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

