:root {
    --primary-color: #0f172a;
    --accent-color: #3b82f6;
    --text-color: #334155;
    --bg-color: #f1f5f9; /* Fondo gris muy suave para la app */
    --card-bg: #ffffff;
    --input-border: #cbd5e1;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.login-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-header { margin-bottom: 30px; }
.login-header svg { margin-bottom: 15px; }
.login-header h2 { font-size: 1.8rem; color: var(--primary-color); margin-bottom: 5px; }
.login-header p { color: #64748b; font-size: 0.95rem; }

.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.9rem; }

.input-wrapper { position: relative; }
.input-wrapper i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}
.input-wrapper input {
    width: 100%;
    padding: 12px 15px 12px 45px; /* Padding izquierdo extra para el icono */
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}
.input-wrapper input:focus { border-color: var(--accent-color); }

.form-footer { display: flex; justify-content: flex-end; margin-bottom: 25px; }
.forgot-password { color: var(--accent-color); text-decoration: none; font-size: 0.9rem; font-weight: 500; }

.btn-login {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}
.btn-login:hover { background-color: #1e293b; }

/* --- DASHBOARD LAYOUT --- */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background-color: var(--bg-color);
}

.sidebar {
    width: 260px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px;
    flex-shrink: 0;
    box-shadow: 4px 0 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.sidebar-header {
    margin-bottom: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
    font-weight: 700;
    padding-left: 10px;
}

.sidebar-menu { list-style: none; }
.sidebar-menu li { margin-bottom: 8px; }

.sidebar-menu a {
    color: #94a3b8;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background-color: rgba(255,255,255,0.1);
    color: white;
    transform: translateX(5px);
}

.logout-link {
    color: #94a3b8;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.logout-link:hover {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.main-content {
    flex-grow: 1;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.top-bar {
    background: white;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.top-bar h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--text-color);
    background: #f8fafc;
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
}

.content-padding { padding: 40px; }

/* --- TABLAS --- */
.table-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

table { width: 100%; border-collapse: collapse; }

thead { background-color: #f8fafc; border-bottom: 2px solid #e2e8f0; }

th { padding: 18px 24px; text-align: left; font-weight: 600; color: #64748b; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }

td { padding: 20px 24px; text-align: left; border-bottom: 1px solid #f1f5f9; color: var(--text-color); font-size: 0.95rem; }

tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 0.2s; }
tbody tr:hover { background-color: #f8fafc; }

.status-badge { padding: 6px 14px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; display: inline-block; }
.status-abierto { background-color: #dbeafe; color: #1e40af; }
.status-proceso { background-color: #fef3c7; color: #92400e; }
.status-cerrado { background-color: #dcfce7; color: #166534; }

/* --- CONFIGURACIÓN --- */
.config-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-width: 600px;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-sync {
    background-color: white;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.btn-sync:hover { background-color: var(--accent-color); color: white; }

/* --- DETALLE TICKET (CHAT) --- */
.ticket-thread {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 40px;
}

.message-bubble {
    padding: 20px;
    border-radius: 12px;
    max-width: 85%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.message-customer {
    background-color: white;
    align-self: flex-start;
    border-left: 4px solid var(--accent-color);
}

.message-agent {
    background-color: #eff6ff; /* Azul muy claro */
    align-self: flex-end;
    border-right: 4px solid var(--primary-color);
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #64748b;
}

.reply-area {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}

/* --- MÉTRICAS --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

.metric-card h3 { font-size: 0.9rem; color: #64748b; margin-bottom: 5px; }
.metric-value { font-size: 1.8rem; font-weight: 700; color: var(--primary-color); }

.ticket-metrics-bar {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    background: #f1f5f9;
    padding: 15px;
    border-radius: 8px;
}

.t-metric { display: flex; flex-direction: column; }
.tm-label { font-size: 0.8rem; color: #64748b; font-weight: 600; text-transform: uppercase; }
.tm-value { font-size: 1.1rem; font-weight: 700; color: var(--primary-color); }

.btn-mini-close {
    background: #fee2e2; color: #ef4444; padding: 4px 10px; border-radius: 6px; 
    text-decoration: none; font-size: 0.8rem; font-weight: 600;
}
.btn-mini-close:hover { background: #fecaca; }

.btn-secondary-action {
    background-color: white; color: var(--primary-color); border: 1px solid var(--primary-color);
    padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: 600;
}
.btn-secondary-action:hover { background-color: #f1f5f9; }