/* === CARDS === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-base);
}
.card:hover { border-color: var(--border-hover); }

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.card-title { font-size: 0.95rem; font-weight: 600; }
.card-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.card-icon {
    width: 40px; height: 40px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.card-icon.amber { background: var(--amber-glow); color: var(--amber); }
.card-icon.emerald { background: var(--emerald-glow); color: var(--emerald); }
.card-icon.red { background: var(--red-glow); color: var(--red); }
.card-icon.blue { background: var(--blue-glow); color: var(--blue); }
.card-icon.purple { background: var(--purple-glow); color: var(--purple); }

/* KPI Cards */
.kpi-card { position: relative; overflow: hidden; }
.kpi-card::after {
    content: ''; position: absolute; top: -50%; right: -50%;
    width: 100%; height: 100%;
    background: radial-gradient(circle, var(--amber-glow) 0%, transparent 70%);
    opacity: 0; transition: opacity var(--transition-slow);
    pointer-events: none;
}
.kpi-card:hover::after { opacity: 1; }
.kpi-value {
    font-size: 2rem; font-weight: 800; letter-spacing: -0.03em;
    line-height: 1.2; margin-bottom: 4px;
}
.kpi-value.amber { color: var(--amber); }
.kpi-value.emerald { color: var(--emerald); }
.kpi-value.red { color: var(--red); }
.kpi-value.blue { color: var(--blue); }
.kpi-label { font-size: 0.82rem; color: var(--text-secondary); }
.kpi-change {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.75rem; font-weight: 600; margin-top: 8px;
    padding: 3px 8px; border-radius: 20px;
}
.kpi-change.up { background: var(--emerald-glow); color: var(--emerald); }
.kpi-change.down { background: var(--red-glow); color: var(--red); }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 10px 20px; border-radius: var(--radius-md);
    font-size: 0.85rem; font-weight: 600; border: none;
    cursor: pointer; transition: all var(--transition-fast);
    font-family: inherit; white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--amber), var(--amber-dark));
    color: var(--text-inverse); box-shadow: var(--shadow-glow-amber);
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-primary); }
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.btn-danger { background: var(--red-glow); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--red); color: white; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 14px 28px; font-size: 0.95rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* === TABLES === */
.table-container {
    background: var(--bg-card); border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg); overflow: hidden;
}
.table-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border-primary);
}
.table-header h3 { font-size: 1rem; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg-tertiary); }
th {
    text-align: left; padding: 12px 16px; font-size: 0.75rem;
    font-weight: 600; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.05em; border-bottom: 1px solid var(--border-primary);
}
td {
    padding: 14px 16px; font-size: 0.85rem; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-primary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }

/* === STATUS BADGES === */
.status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.status::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
}
.status.active { background: var(--emerald-glow); color: var(--emerald); }
.status.active::before { background: var(--emerald); animation: pulse-dot 2s infinite; }
.status.inactive { background: var(--bg-tertiary); color: var(--text-muted); }
.status.inactive::before { background: var(--text-muted); }
.status.warning { background: var(--amber-glow); color: var(--amber); }
.status.warning::before { background: var(--amber); }
.status.danger { background: var(--red-glow); color: var(--red); }
.status.danger::before { background: var(--red); animation: pulse-dot 1s infinite; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 0.82rem; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px; background: var(--bg-input);
    border: 1px solid var(--border-primary); border-radius: var(--radius-md);
    color: var(--text-primary); font-size: 0.88rem;
    font-family: inherit; transition: border-color var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-glow);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-input::placeholder { color: var(--text-muted); }

/* === MODAL === */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px); z-index: var(--z-modal);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: all var(--transition-base);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--bg-secondary); border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl); width: 90%; max-width: 560px;
    max-height: 85vh; overflow-y: auto; transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border-primary);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.2rem; cursor: pointer; padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border-primary);
    display: flex; justify-content: flex-end; gap: 10px;
}

/* === MAP CONTAINER === */
.map-container {
    width: 100%; height: 100%; min-height: 400px;
    border-radius: var(--radius-lg); overflow: hidden;
    border: 1px solid var(--border-primary); position: relative;
}
.map-container #map { width: 100%; height: 100%; }
.map-overlay {
    position: absolute; top: 12px; left: 12px; z-index: 10;
    display: flex; flex-direction: column; gap: 8px;
}
.map-legend {
    background: var(--bg-secondary); border: 1px solid var(--border-primary);
    border-radius: var(--radius-md); padding: 12px 16px;
}
.map-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 4px; }
.map-legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* === ACTIVITY FEED === */
.activity-feed { display: flex; flex-direction: column; gap: 1px; }
.activity-item {
    display: flex; gap: 12px; padding: 14px 0;
    border-bottom: 1px solid var(--border-primary);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 8px; height: 8px; border-radius: 50%;
    margin-top: 7px; flex-shrink: 0;
}
.activity-content { flex: 1; }
.activity-text { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.activity-text strong { color: var(--text-primary); font-weight: 600; }
.activity-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* === TOAST === */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-radius: var(--radius-md);
    background: var(--bg-secondary); border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg); min-width: 300px;
    animation: slideInRight 0.3s ease;
}
.toast.success { border-color: var(--emerald); }
.toast.error { border-color: var(--red); }
.toast.warning { border-color: var(--amber); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-message { font-size: 0.85rem; flex: 1; }

/* === TABS === */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-primary); margin-bottom: 20px; }
.tab {
    padding: 10px 18px; font-size: 0.85rem; font-weight: 500;
    color: var(--text-muted); cursor: pointer; border: none; background: none;
    border-bottom: 2px solid transparent; transition: all var(--transition-fast);
    font-family: inherit;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }

/* === EMPTY STATE === */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 60px 20px; text-align: center;
}
.empty-state i { font-size: 3rem; color: var(--text-muted); margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; color: var(--text-muted); max-width: 400px; margin-bottom: 20px; }

/* === EMPRESA SELECTOR (MULTI-TENANT) === */
.empresa-selector {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; background: var(--bg-primary);
    border: 1px solid var(--border-primary); border-radius: var(--radius-md);
    cursor: pointer; transition: all var(--transition-fast);
}
.empresa-selector:hover { border-color: var(--amber); }
.empresa-selector .empresa-logo {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    background: var(--amber-glow); display: flex; align-items: center;
    justify-content: center; font-size: 0.75rem; color: var(--amber); font-weight: 700;
}
.empresa-selector .empresa-name { font-size: 0.82rem; font-weight: 600; }
.empresa-selector i { margin-left: auto; font-size: 0.7rem; color: var(--text-muted); }

/* Dropdown de empresas */
.empresa-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-secondary); border: 1px solid var(--border-primary);
    border-radius: var(--radius-md); margin-top: 4px;
    box-shadow: var(--shadow-lg); z-index: 50; display: none;
}
.empresa-dropdown.open { display: block; }
.empresa-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; cursor: pointer;
    transition: background var(--transition-fast);
}
.empresa-dropdown-item:hover { background: var(--bg-tertiary); }
.empresa-dropdown-item.active { background: var(--amber-glow); }
.empresa-dropdown-item .add-new { color: var(--amber); font-weight: 600; }

/* === ALERTS === */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
}
.alert-danger {
    background: var(--red-glow);
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.2);
}
.alert-info {
    background: var(--blue-glow);
    color: var(--blue);
    border-color: rgba(59, 130, 246, 0.2);
}

/* === MAP ENHANCEMENTS === */
.map-quick-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    backdrop-filter: blur(5px);
}
.map-quick-btn:hover {
    background: rgba(51, 65, 85, 0.9);
    transform: translateX(5px);
    border-color: var(--amber);
}
.glass-panel {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}
.pulse { animation: pulse 1.5s infinite; }

/* ============================================================
   === NOTIFICATION PANEL =====================================
   ============================================================ */

/* Overlay oscuro detrás del panel */
#notif-overlay {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    opacity: 0; visibility: hidden;
    transition: all 0.25s ease;
}
#notif-overlay.visible { opacity: 1; visibility: visible; }

/* Panel lateral */
#notif-panel {
    position: fixed; top: 0; right: -420px; bottom: 0;
    width: 380px; z-index: 901;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    box-shadow: -8px 0 40px rgba(0,0,0,0.4);
    display: flex; flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#notif-panel.open { right: 0; }

/* Header del panel */
.notif-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px; border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}
.notif-panel-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 1rem; font-weight: 700; color: var(--text-primary);
}
.notif-panel-title i { color: var(--amber); font-size: 1.1rem; }
.notif-panel-actions { display: flex; gap: 6px; }
.notif-mark-all, .notif-close-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 6px; border-radius: var(--radius-sm);
    font-size: 0.95rem; transition: all var(--transition-fast);
}
.notif-mark-all:hover { color: var(--amber); background: var(--amber-glow); }
.notif-close-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }

/* Filtros */
.notif-panel-filters {
    display: flex; gap: 6px; padding: 12px 16px;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0; overflow-x: auto;
}
.notif-filter {
    padding: 5px 12px; border-radius: 20px; font-size: 0.75rem;
    font-weight: 600; border: 1px solid var(--border-primary);
    background: var(--bg-tertiary); color: var(--text-secondary);
    cursor: pointer; transition: all var(--transition-fast);
    white-space: nowrap; font-family: inherit;
}
.notif-filter:hover { border-color: var(--amber); color: var(--amber); }
.notif-filter.active { background: var(--amber-glow); color: var(--amber); border-color: var(--amber); }

/* Lista de notificaciones */
.notif-list {
    flex: 1; overflow-y: auto; padding: 8px 0;
}
.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-thumb { background: var(--border-primary); border-radius: 2px; }

/* Item individual */
.notif-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px; cursor: pointer; position: relative;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-primary);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-tertiary); }
.notif-item.unread { background: rgba(245, 158, 11, 0.04); }

.notif-item-icon {
    width: 38px; height: 38px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; flex-shrink: 0;
}
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title {
    font-size: 0.85rem; font-weight: 700; color: var(--text-primary);
    margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-item-text {
    font-size: 0.78rem; color: var(--text-secondary);
    line-height: 1.4; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notif-item-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 5px; }

/* Punto indicador de no leído */
.notif-unread-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--amber); flex-shrink: 0; margin-top: 6px;
    animation: pulse-dot 2s infinite;
}

/* Badge numérico en la campana */
.notif-counter-badge {
    position: absolute; top: 2px; right: 2px;
    background: var(--red); color: white;
    font-size: 0.6rem; font-weight: 800;
    min-width: 16px; height: 16px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px; line-height: 1;
    box-shadow: 0 0 0 2px var(--bg-primary);
    animation: pulse-dot 1.5s infinite;
}

/* Empty state */
.notif-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 60px 20px; text-align: center;
    color: var(--text-muted);
}
.notif-empty i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }
.notif-empty p { font-size: 0.85rem; }

/* Footer con permiso push */
.notif-panel-footer {
    border-top: 1px solid var(--border-primary);
    flex-shrink: 0;
}
.notif-permission {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; font-size: 0.78rem; color: var(--text-secondary);
}
.notif-permission i { color: var(--blue); }
.notif-permission span { flex: 1; }
.notif-permission button {
    padding: 5px 12px; border-radius: var(--radius-sm);
    background: var(--blue-glow); color: var(--blue);
    border: 1px solid rgba(59,130,246,0.3);
    font-size: 0.75rem; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: all var(--transition-fast);
}
.notif-permission button:hover { background: var(--blue); color: white; }

/* Responsive: panel más angosto en móviles */
@media (max-width: 480px) {
    #notif-panel { width: 100%; right: -100%; }
}
