/* ============================================================
   MiSoporte - Estilos Principales
   ============================================================ */

/* --- VARIABLES --- */
:root {
    --ms-primary:     #0d6efd;
    --ms-primary-dark:#0a58ca;
    --ms-sidebar-bg:  #1a1f2e;
    --ms-sidebar-w:   260px;
    --ms-topbar-h:    60px;
    --ms-text:        #212529;
    --ms-muted:       #6c757d;
    --ms-border:      #dee2e6;
    --ms-bg:          #f0f2f5;
    --ms-card:        #ffffff;
    --ms-success:     #198754;
    --ms-danger:      #dc3545;
    --ms-warning:     #ffc107;
    --ms-info:        #0dcaf0;
    --ms-purple:      #6f42c1;
    --transition:     all 0.2s ease;
}

/* --- RESET Y BASE --- */
* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--ms-bg);
    color: var(--ms-text);
    margin: 0;
    padding: 0;
}

/* --- LOGIN --- */
.login-body {
    background: linear-gradient(135deg, #f0f2f5 0%, #e8ecf0 100%);
    min-height: 100vh;
    display: flex;
    align-items: stretch;
}

.login-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.login-side {
    background: linear-gradient(160deg, #0d6efd 0%, #0a58ca 50%, #084298 100%);
    width: 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.login-side-content {
    color: white;
    max-width: 340px;
}

.login-logo-big {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.login-side-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.login-side-content p {
    opacity: 0.85;
    font-size: 1rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 0;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    opacity: 0.9;
    font-size: 0.95rem;
}

.login-features i {
    font-size: 1rem;
    color: #a8d8a8;
}

.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-form-inner {
    width: 100%;
    max-width: 420px;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ms-text);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--ms-muted);
    margin-bottom: 1.75rem;
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--ms-muted);
    font-size: 0.8rem;
}

/* --- LAYOUT PRINCIPAL (POST LOGIN) --- */
.ms-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--ms-sidebar-w);
    height: 100vh;
    background: var(--ms-sidebar-bg);
    overflow-y: auto;
    z-index: 1000;
    transition: var(--transition);
}

.ms-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-decoration: none;
}

.ms-sidebar-brand span {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.ms-sidebar-brand i {
    color: var(--ms-primary);
    font-size: 1.4rem;
}

.ms-nav-section {
    padding: 1.25rem 1rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
}

.ms-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 6px;
    margin: 2px 0.5rem;
    font-size: 0.9rem;
    transition: var(--transition);
}

.ms-nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.ms-nav-link.active {
    background: var(--ms-primary);
    color: white;
}

.ms-nav-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
}

.ms-nav-badge {
    margin-left: auto;
    background: var(--ms-danger);
    color: white;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* --- TOPBAR --- */
.ms-topbar {
    position: fixed;
    top: 0;
    left: var(--ms-sidebar-w);
    right: 0;
    height: var(--ms-topbar-h);
    background: white;
    border-bottom: 1px solid var(--ms-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 999;
    gap: 1rem;
}

.ms-topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ms-text);
    flex: 1;
}

.ms-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ms-notif-btn {
    position: relative;
    background: none;
    border: 1px solid var(--ms-border);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ms-muted);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.ms-notif-btn:hover {
    background: var(--ms-bg);
    color: var(--ms-text);
}

.ms-notif-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--ms-danger);
    color: white;
    font-size: 0.65rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.ms-user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid var(--ms-border);
    border-radius: 8px;
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    text-decoration: none;
    color: var(--ms-text);
    transition: var(--transition);
}

.ms-user-menu:hover {
    background: var(--ms-bg);
}

.ms-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ms-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

/* --- CONTENIDO PRINCIPAL --- */
.ms-content {
    margin-left: var(--ms-sidebar-w);
    padding-top: var(--ms-topbar-h);
    min-height: 100vh;
}

.ms-page {
    padding: 1.75rem;
}

/* --- CARDS --- */
.ms-card {
    background: var(--ms-card);
    border: 1px solid var(--ms-border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.ms-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ms-text);
}

/* --- STATS CARDS --- */
.stat-card {
    background: var(--ms-card);
    border: 1px solid var(--ms-border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.yellow { background: #fef9c3; color: #a16207; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-icon.gray   { background: #f3f4f6; color: #374151; }
.stat-icon.red    { background: #fee2e2; color: #b91c1c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--ms-muted);
}

/* --- TABLAS --- */
.ms-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.ms-table th {
    background: var(--ms-bg);
    padding: 0.65rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ms-muted);
    border-bottom: 1px solid var(--ms-border);
}

.ms-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.ms-table tr:hover td {
    background: #fafafa;
}

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

/* --- BADGES DE ESTADO Y PRIORIDAD --- */
.badge {
    font-size: 0.75rem;
    padding: 0.3em 0.7em;
    border-radius: 6px;
    font-weight: 600;
}

.bg-purple {
    background-color: var(--ms-purple) !important;
    color: white !important;
}

.urgente-pulse {
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* --- FORMULARIOS --- */
.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--ms-border);
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--ms-primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.12);
}

/* --- BOTONES --- */
.btn {
    border-radius: 8px;
    font-size: 0.9rem;
    padding: 0.45rem 1rem;
    font-weight: 500;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--ms-primary-dark);
    border-color: var(--ms-primary-dark);
}

/* --- MENSAJES HILO DE TICKET --- */
.mensaje-bubble {
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    max-width: 85%;
}

.mensaje-cliente {
    background: #e8f0fe;
    border: 1px solid #c2d4f8;
    margin-right: auto;
}

.mensaje-staff {
    background: #e8f8f0;
    border: 1px solid #b7e4cc;
    margin-left: auto;
}

.mensaje-interna {
    background: #fff8e1;
    border: 1px dashed #f0c040;
    margin-right: auto;
}

.mensaje-meta {
    font-size: 0.78rem;
    color: var(--ms-muted);
    margin-bottom: 0.35rem;
}

/* --- TIMELINE DE TICKET --- */
.ticket-timeline {
    position: relative;
    padding-left: 2rem;
}

.ticket-timeline::before {
    content: '';
    position: absolute;
    left: 0.55rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--ms-border);
}

.timeline-item {
    position: relative;
    margin-bottom: 1rem;
}

.timeline-dot {
    position: absolute;
    left: -1.55rem;
    top: 0.35rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ms-primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--ms-primary);
}

/* --- RESPONSIVE --- */
@media (max-width: 991px) {
    .ms-sidebar {
        transform: translateX(-100%);
    }
    .ms-sidebar.show {
        transform: translateX(0);
    }
    .ms-content {
        margin-left: 0;
    }
    .ms-topbar {
        left: 0;
    }
    .ms-page {
        padding: 1rem;
    }
}

/* --- UTILIDADES --- */
.fw-500 { font-weight: 500; }
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cursor-pointer { cursor: pointer; }
.border-start-primary { border-left: 3px solid var(--ms-primary) !important; }
