:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --topbar-height: 60px;
    --content-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    --accent: #3b82f6;
    --accent-soft: #dbeafe;
}

* {
    box-sizing: border-box;
}

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

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

a:hover {
    color: #2563eb;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-brand small {
    display: block;
    margin-top: 0.25rem;
    color: #94a3b8;
    font-size: 0.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0.75rem 0.75rem 0.35rem;
    margin-top: 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.5rem;
    color: #cbd5e1;
    margin-bottom: 0.15rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav .nav-icon {
    width: 1.25rem;
    text-align: center;
    opacity: 0.9;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

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

.user-badge {
    font-size: 0.875rem;
    color: #475569;
}

.content {
    padding: 1.5rem;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
}

.stat-card {
    border-left: 4px solid var(--accent);
}

.stat-card.warning {
    border-left-color: #f59e0b;
}

.stat-card.success {
    border-left-color: #10b981;
}

.stat-card.danger {
    border-left-color: #ef4444;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    color: #64748b;
    font-size: 0.875rem;
}

.table > :not(caption) > * > * {
    vertical-align: middle;
}

.badge-prioridad-urgente {
    background: #ef4444;
}

.badge-prioridad-alta {
    background: #f59e0b;
}

.badge-prioridad-media {
    background: #3b82f6;
}

.badge-prioridad-baja {
    background: #64748b;
}

.comentario-interno {
    background: #fff7ed;
    border-left: 3px solid #f59e0b;
}

.llamada-activa-pulse {
    animation: pulse 1.5s infinite;
}

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

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #3b82f6 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 1rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.sidebar-toggle {
    display: none;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }
}

/* Softphone global (topbar + llamadas entrantes) */
.softphone-host {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.softphone-widget {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding-right: 0.5rem;
    border-right: 1px solid #e2e8f0;
    margin-right: 0.5rem;
}

.softphone-widget-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.softphone-widget-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.softphone-widget-status.offline { background: #f1f5f9; color: #64748b; }
.softphone-widget-status.connecting { background: #fef3c7; color: #b45309; }
.softphone-widget-status.registered { background: #d1fae5; color: #047857; }
.softphone-widget-status.incall { background: #ede9fe; color: #6d28d9; }
.softphone-widget-status.error { background: #fee2e2; color: #b91c1c; }

.softphone-widget-incoming {
    display: none;
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    max-width: 320px;
}

.softphone-widget-incoming.show {
    display: block;
}

.softphone-widget-incoming-card {
    background: #fff;
    border: 1px solid #a7f3d0;
    border-radius: 0.75rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    padding: 1rem;
}
