/* System Font & Core Reset */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-dark: #0B0F19;
    --bg-card: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --primary-gradient: linear-gradient(135deg, #6366F1 0%, #14B8A6 100%);
    --primary-color: #6366F1;
    --accent-color: #14B8A6;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --success-color: #10B981;
    --text-white: #F9FAFB;
    --text-gray: #9CA3AF;
    --text-muted: #6B7280;
    --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-white);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(20, 184, 166, 0.15) 0px, transparent 50%);
}

/* Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    background-color: rgba(10, 15, 30, 0.85);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    backdrop-filter: blur(20px);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    color: var(--text-gray);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.nav-item:hover, .nav-item.active {
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    border-left: 3px solid #14B8A6;
    background: rgba(99, 102, 241, 0.1);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Main Content Area */
main {
    padding: 2.5rem;
    overflow-y: auto;
    max-height: 100vh;
}

/* Header Component */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.top-header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.top-header p {
    color: var(--text-gray);
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Custom Premium Buttons */
.btn-primary {
    background: var(--primary-gradient);
    color: var(--text-white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-white);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-danger {
    background: var(--danger-color);
    color: var(--text-white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-danger:hover {
    background: #DC2626;
}

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.15);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: var(--transition-fast);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.stat-info h3 {
    font-size: 0.85rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.stat-info p {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Sections Structure */
.content-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

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

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

/* Glass Card containers */
.glass-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 2rem;
    backdrop-filter: blur(16px);
    margin-bottom: 2rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tables Styling */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 1rem;
    color: var(--text-gray);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

td {
    padding: 1.15rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.95rem;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Badges */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    text-transform: uppercase;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34D399;
}

.badge-info {
    background-color: rgba(6, 182, 212, 0.15);
    color: #22D3EE;
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: #FBBF24;
}

.badge-danger {
    background-color: rgba(239, 68, 110, 0.15);
    color: #F87171;
}

.badge-primary {
    background-color: rgba(99, 102, 241, 0.15);
    color: #818CF8;
}

/* Voice Call Simulator Panel */
.voice-console-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
}

.terminal-box {
    background-color: #05070F;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    height: 380px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Courier New', Courier, monospace;
}

.terminal-header {
    background-color: #0A0D1A;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.terminal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-red { background-color: var(--danger-color); }
.dot-yellow { background-color: var(--warning-color); }
.dot-green { background-color: var(--success-color); }

.terminal-title {
    color: var(--text-gray);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.terminal-body {
    padding: 1rem;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.terminal-line {
    line-height: 1.4;
}

.line-system { color: #818CF8; }
.line-agent { color: #34D399; }
.line-user { color: #FBBF24; }

.call-control-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.dial-animation {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
    position: relative;
    margin-bottom: 1rem;
}

.dial-animation svg {
    width: 32px;
    height: 32px;
    animation: shake 0.5s infinite alternate;
}

@keyframes shake {
    0% { transform: rotate(-10deg); }
    100% { transform: rotate(10deg); }
}

.dial-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    animation: pulse 1.5s infinite ease-out;
    opacity: 0;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(5, 7, 15, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: #0E1322;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 500px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.form-group {
    margin-bottom: 1.25rem;
}

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

.form-control {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-white);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: rgba(255, 255, 255, 0.08);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Tablero Kanban */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    align-items: flex-start;
}

.kanban-column {
    flex: 1 0 240px;
    min-width: 240px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem;
    transition: var(--transition-fast);
}

.kanban-column.drag-over {
    border-color: var(--accent-color);
    background: rgba(20, 184, 166, 0.08);
}

.kanban-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.kanban-count {
    color: var(--text-gray);
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 0.1rem 0.6rem;
}

.kanban-cards {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 80px;
    max-height: 62vh;
    overflow-y: auto;
    padding-right: 4px;
}

.kanban-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem;
    cursor: grab;
    transition: var(--transition-fast);
}

.kanban-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

.kanban-card.dragging {
    opacity: 0.45;
    cursor: grabbing;
}

.kanban-card-name {
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 0.2rem;
}

.kanban-card-sub {
    color: var(--text-gray);
    font-size: 0.8rem;
    margin-bottom: 0.6rem;
}

.kanban-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.kanban-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.kanban-card-id {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.kanban-card-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
}

.kanban-card-dates {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 0.45rem;
}

.kanban-empty {
    color: var(--text-muted);
    text-align: center;
    font-size: 0.85rem;
    padding: 0.75rem 0;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.18) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(20, 184, 166, 0.18) 0px, transparent 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem;
    width: 380px;
    max-width: 90vw;
    backdrop-filter: blur(16px);
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.login-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem auto;
    background: var(--primary-gradient);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: #fff;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Logo oficial en el modal de login */
.login-logo-img {
    display: block;
    width: 96px;
    height: 96px;
    object-fit: contain;
    margin: 0 auto 1rem auto;
    border-radius: 50%;
    background: #111;
    padding: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

/* Logo oficial en el sidebar */
.logo-img {
    display: block;
    width: 100%;
    max-width: 200px;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
}

.login-card h2 {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.login-card .form-group {
    text-align: left;
}

/* Conversaciones (Chat de WhatsApp) */
.chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 600px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.01);
}

.chat-list {
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-empty-hint {
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.5;
}

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: var(--transition-fast);
}

.chat-list-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.chat-list-item.active {
    background: rgba(99, 102, 241, 0.12);
    border-left: 3px solid var(--accent-color);
}

.chat-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
}

.chat-list-info {
    overflow: hidden;
    flex-grow: 1;
}

.chat-list-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.chat-list-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-preview {
    color: var(--text-gray);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.15rem;
}

.chat-thread {
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.chat-thread-empty {
    margin: auto;
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 2rem;
    text-align: center;
}

.chat-thread-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.chat-thread-name {
    font-weight: 600;
}

.chat-thread-sub {
    color: var(--text-gray);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.chat-messages {
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-bubble {
    max-width: 72%;
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.bubble-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.bubble-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    text-align: right;
}

.bubble-in {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.bubble-out {
    align-self: flex-end;
    background: rgba(20, 184, 166, 0.18);
    border: 1px solid rgba(20, 184, 166, 0.35);
    border-bottom-right-radius: 4px;
}

.chat-note {
    align-self: center;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-gray);
    font-size: 0.78rem;
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    text-align: center;
    max-width: 85%;
}

/* Responsive Styles */
@media(max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none; /* Sería reemplazado por un menú móvil */
    }
    .voice-console-grid {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
