/**
 * ESTILOS DEL PANEL - CHATBOT RUSAMI
 * Desarrollado por Nynel MKT
 * Diseño profesional con colores claros y acentos suaves
 */

:root {
    --primary-color: #1e3a5f;
    --primary-light: #2d5a8a;
    --secondary-color: #5b8fb9;
    --accent-color: #7eb8da;
    --success-color: #4caf7c;
    --warning-color: #e9a84a;
    --danger-color: #dc3545;
    --info-color: #17a2b8;

    /* Fondos con tonos suaves */
    --bg-gradient: linear-gradient(135deg, #f0f4f8 0%, #e8eff5 50%, #f5f8fc 100%);
    --bg-color: #f0f4f8;
    --bg-sidebar: linear-gradient(180deg, #1e3a5f 0%, #2d5a8a 100%);
    --card-bg: #ffffff;
    --card-hover: #fafcff;

    --text-color: #2c3e50;
    --text-muted: #6c757d;
    --text-light: #94a3b8;
    --border-color: #d1dce6;

    --shadow: 0 2px 12px rgba(30, 58, 95, 0.08);
    --shadow-hover: 0 8px 25px rgba(30, 58, 95, 0.12);
    --shadow-card: 0 4px 15px rgba(30, 58, 95, 0.06);

    --radius: 10px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--secondary-color);
}

a:hover {
    color: var(--primary-color);
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8a 50%, #5b8fb9 100%);
    padding: 20px;
}

.login-box {
    background: rgba(255, 255, 255, 0.98);
    padding: 50px 40px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 420px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.login-logo {
    max-width: 180px;
    margin-bottom: 30px;
}

.login-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 35px;
    font-size: 15px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 15px;
    transition: all 0.3s ease;
    background: #fafcff;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(91, 143, 185, 0.15);
    background: #fff;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 58, 95, 0.25);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--secondary-color) 100%);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #3d9970 0%, var(--success-color) 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(76, 175, 124, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #e0943e 0%, var(--warning-color) 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #c82333 0%, var(--danger-color) 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #138496 0%, var(--info-color) 100%);
    color: white;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-icon {
    padding: 10px;
    border-radius: 50%;
}

.error-message {
    background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
    color: var(--danger-color);
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: none;
    border: 1px solid #fecaca;
}

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

/* Sidebar */
.sidebar {
    width: 270px;
    background: var(--bg-sidebar);
    color: white;
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

.sidebar-logo {
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
}

.sidebar-logo img {
    max-width: 140px;
    filter: brightness(0) invert(1);
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    color: rgba(255, 255, 255, 0.75);
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    font-weight: 500;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--accent-color);
}

.sidebar-nav a i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.85);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 270px;
    padding: 28px 35px;
    background: var(--bg-gradient);
    min-height: 100vh;
}

/* Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 30px;
    font-weight: 700;
    color: var(--primary-color);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 15px;
    margin-top: 4px;
}

/* =====================================================
   CARDS & STATS
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    padding: 26px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
    border: 1px solid rgba(209, 220, 230, 0.5);
}

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

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.stat-icon.blue {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
}
.stat-icon.green {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
}
.stat-icon.orange {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: #ef6c00;
}
.stat-icon.red {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    color: #c62828;
}
.stat-icon.purple {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    color: #7b1fa2;
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 6px;
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
    border: 1px solid rgba(209, 220, 230, 0.5);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #fafcff 0%, #f8fafc 100%);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.card-body {
    padding: 24px;
}

/* =====================================================
   TABLES
   ===================================================== */
.table-container {
    overflow-x: auto;
}

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

table th,
table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background: linear-gradient(180deg, #f8fafc 0%, #f0f4f8 100%);
    font-weight: 600;
    color: var(--primary-color);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tr:hover {
    background: linear-gradient(90deg, #fafcff 0%, #f5f8fc 100%);
}

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

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}
.badge-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    color: #856404;
}
.badge-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}
.badge-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}
.badge-primary {
    background: linear-gradient(135deg, #cce5ff 0%, #b8daff 100%);
    color: #004085;
}
.badge-secondary {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    color: #495057;
}

/* =====================================================
   CHAT / CONVERSACIONES
   ===================================================== */
.chat-container {
    display: flex;
    height: calc(100vh - 160px);
    gap: 24px;
}

.chat-list {
    width: 360px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(209, 220, 230, 0.5);
}

.chat-list-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, #fafcff 0%, #f8fafc 100%);
}

.chat-list-items {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-item:hover,
.chat-item.active {
    background: linear-gradient(90deg, #f0f7ff 0%, #e8f4ff 100%);
}

.chat-item.active {
    border-left: 4px solid var(--secondary-color);
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.chat-item-name {
    font-weight: 600;
    color: var(--primary-color);
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-item-preview {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, var(--danger-color) 0%, #e74c5e 100%);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
}

/* Chat Window */
.chat-window {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(209, 220, 230, 0.5);
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #fafcff 0%, #f8fafc 100%);
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f0f4f8 100%);
}

.message {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: 18px;
    position: relative;
}

.message.incoming {
    background: white;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.message.outgoing {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(91, 143, 185, 0.3);
}

.message.outgoing.bot {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
}

.message-time {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 6px;
    text-align: right;
}

.chat-input {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    background: linear-gradient(180deg, #fafcff 0%, #f8fafc 100%);
}

.chat-input input {
    flex: 1;
}

/* =====================================================
   CLIENTE DETALLE
   ===================================================== */
.cliente-header {
    display: flex;
    gap: 24px;
    margin-bottom: 28px;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f0f7ff 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(209, 220, 230, 0.5);
}

.cliente-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(91, 143, 185, 0.3);
}

.cliente-info h2 {
    font-size: 24px;
    color: var(--primary-color);
    font-weight: 700;
}

.cliente-info p {
    color: var(--text-muted);
    margin-top: 4px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f0f4f8 100%);
    border-radius: var(--radius);
    border: 1px solid rgba(209, 220, 230, 0.5);
}

.info-item label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span {
    font-weight: 600;
    color: var(--text-color);
}

/* =====================================================
   FORMS
   ===================================================== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group.checkbox input {
    width: 20px;
    height: 20px;
    accent-color: var(--secondary-color);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%231e3a5f' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
}

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

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 58, 95, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.3s ease;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 22px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #fafcff 0%, #f8fafc 100%);
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    line-height: 1;
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #fafcff 100%);
}

/* =====================================================
   ALERTS
   ===================================================== */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-color: #b1dfbb;
}
.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    color: #856404;
    border-color: #ffeeba;
}
.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-color: #f5c6cb;
}
.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-color: #bee5eb;
}

/* =====================================================
   LOADING
   ===================================================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 50px;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border-color);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .main-content {
        margin-left: 220px;
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .chat-container {
        flex-direction: column;
    }
    .chat-list {
        width: 100%;
        height: 280px;
    }
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.p-20 { padding: 20px; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-10 { gap: 10px; }
.gap-20 { gap: 20px; }
.hidden { display: none !important; }
