/* ═══════════════════════════════════════════════════════
   SIGOF — Componentes compartidos (layout, modales, tablas…)
   ═══════════════════════════════════════════════════════ */

/* ─── CARGA INICIAL ─── */
.app-loader {
    position: fixed; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: var(--bg-primary); color: var(--text-secondary); font-size: 13px; z-index: 2000;
}

/* ─── SIDEBAR ─── */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform 0.25s ease;
}
.sidebar-header { padding: 20px 18px 16px; }
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.sidebar-logo-mark {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, #6366f1, #4338ca);
    box-shadow: 0 6px 16px rgba(99,102,241,0.35);
}
.sidebar-logo-mark svg { width: 19px; height: 19px; fill: #fff; }
.sidebar-logo h1 { font-size: 16px; font-weight: 800; letter-spacing: 0.8px; line-height: 1.2; }
.sidebar-logo span { display: block; font-size: 11px; color: var(--text-muted); }
.sidebar-cta { padding: 4px 14px 10px; }
.sidebar-cta .btn { padding: 10px; }
.sidebar-nav { flex: 1; padding: 6px 12px; overflow-y: auto; }
.nav-section {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.9px;
    color: var(--text-muted); padding: 14px 10px 6px;
}
.nav-item {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px 12px; margin-bottom: 2px;
    border: none; border-radius: var(--radius-sm); background: transparent;
    color: var(--text-secondary); font: 500 13px var(--font-family); text-align: left;
    cursor: pointer; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-bg); color: var(--accent-hover); font-weight: 600; }
.nav-item.active::before {
    content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item svg { flex-shrink: 0; }
.nav-badge {
    margin-left: auto; min-width: 20px; text-align: center;
    background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
}
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border-color); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--bg-card); }
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.role-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.role-dot.role-admin { background: var(--warning); }
.role-dot.role-tecnico { background: var(--info); }
.role-dot.role-solicitante { background: var(--success); }
.btn-logout {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-radius: 8px; color: var(--text-muted); cursor: pointer;
}
.btn-logout:hover { background: var(--danger-bg); color: var(--danger); }
.session-hint { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--text-muted); padding: 8px 4px 0; }

/* ─── TOPBAR ─── */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-height);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
    background: rgba(10,12,18,0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 17px; font-weight: 700; line-height: 1.2; }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-date { font-size: 12px; color: var(--text-secondary); text-transform: capitalize; }

/* ─── LAYOUT ─── */
.main-content { margin-left: var(--sidebar-width); min-height: 100vh; }
.content-area { padding: 24px 28px 40px; max-width: 1600px; }
.view-enter { animation: viewIn 0.25s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sidebar-backdrop { display: none; }
.mobile-only { display: none !important; }

/* ─── BOTONES DE ICONO ─── */
.icon-btn {
    width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid transparent; border-radius: 8px;
    color: var(--text-secondary); cursor: pointer; font-size: 14px; transition: 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); border-color: var(--border-color); color: var(--text-primary); }
.icon-btn.icon-danger:hover { background: var(--danger-bg); border-color: rgba(239,68,68,0.3); }

/* ─── AVATARES / PERSONAS ─── */
.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    border-radius: 50%; color: #fff; font-weight: 700; letter-spacing: 0.3px;
}
.person { display: flex; align-items: center; gap: 9px; min-width: 0; }

/* ─── TABLAS ─── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 14px 16px; border-bottom: 1px solid var(--border-color);
}
.table-toolbar .form-control { width: auto; min-width: 140px; padding: 8px 12px; font-size: 13px; }
.toolbar-end { margin-left: auto; }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-box .form-control { width: 100%; padding-left: 36px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 11px 14px; text-align: left; white-space: nowrap;
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border-color);
}
.data-table td { padding: 12px 14px; font-size: 13px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .r { text-align: right; }
.data-table .c { text-align: center; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.row-muted td { opacity: 0.55; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.money { color: var(--success); font-weight: 600; font-variant-numeric: tabular-nums; }

.folio {
    font-family: Consolas, monospace; font-weight: 700; font-size: 12px;
    color: var(--accent-hover); background: var(--accent-bg);
    padding: 2px 8px; border-radius: 5px; white-space: nowrap;
}

/* ─── ETIQUETAS ─── */
.tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
    background: var(--bg-hover); color: var(--text-secondary); white-space: nowrap;
}
.tag-success { background: var(--success-bg); color: var(--success); }
.tag-warning { background: var(--warning-bg); color: var(--warning); }
.tag-danger  { background: var(--danger-bg);  color: var(--danger); }
.you-pill { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--accent-bg); color: var(--accent-hover); margin-left: 4px; }
.muted-pill { font-size: 12px; color: var(--text-muted); font-style: italic; }
.online-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--success); font-weight: 600; }
.online-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* ─── PAGINACIÓN ─── */
.pagination {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
    padding: 12px 16px; border-top: 1px solid var(--border-color);
    font-size: 12px; color: var(--text-muted);
}
.pagination b { color: var(--text-secondary); }
.pagination-btns { display: flex; gap: 4px; align-items: center; }
.pagination-btn {
    min-width: 32px; height: 32px; padding: 0 8px;
    background: transparent; border: 1px solid var(--border-color); border-radius: 8px;
    color: var(--text-secondary); font-size: 12px; cursor: pointer; transition: 0.15s;
}
.pagination-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.pagination-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination-gap { padding: 0 4px; }

/* ─── SKELETON ─── */
.skeleton-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.skeleton-row {
    height: 40px; border-radius: 8px;
    background: linear-gradient(90deg, var(--bg-hover) 25%, rgba(255,255,255,0.06) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── MODALES ─── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: none; align-items: center; justify-content: center; padding: 20px;
    background: rgba(3,5,10,0.72); backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
    width: 100%; max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.55);
    animation: modalIn 0.2s ease;
}
.modal-sm { max-width: 420px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 980px; }
@keyframes modalIn { from { transform: scale(0.96) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding: 20px 24px 16px; border-bottom: 1px solid var(--border-color);
}
.modal-header h2 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-subtitle { margin-top: 6px; font-size: 12px; color: var(--text-secondary); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.modal-close {
    width: 32px; height: 32px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover); border: none; border-radius: 50%;
    color: var(--text-secondary); cursor: pointer; transition: 0.15s;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 24px; border-top: 1px solid var(--border-color);
    background: rgba(255,255,255,0.015); border-radius: 0 0 16px 16px;
}
.confirm-text { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }
.confirm-text b { color: var(--text-primary); }

/* ─── FORMULARIOS ─── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }
.input-prefix .form-control { padding-left: 26px; }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; cursor: pointer; }
.mt-2 { margin-top: 8px; }

/* ─── TOAST ─── */
.toast {
    position: fixed; bottom: 24px; right: 24px; z-index: 3000;
    display: none; align-items: center; gap: 12px;
    max-width: 400px; padding: 13px 18px;
    background: var(--bg-secondary); border: 1px solid var(--border-hover); border-radius: 12px;
    font-size: 13px; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.toast.show { display: flex; animation: toastIn 0.3s ease; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-icon {
    width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast-error .toast-icon   { background: var(--danger-bg);  color: var(--danger); }
.toast-warning .toast-icon { background: var(--warning-bg); color: var(--warning); }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); width: 270px; box-shadow: 20px 0 60px rgba(0,0,0,0.5); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; }
    .main-content { margin-left: 0; }
    .content-area { padding: 16px; }
    .topbar { padding: 0 16px; }
    .topbar-date, .topbar-subtitle { display: none; }
    .mobile-only { display: inline-flex !important; }
    .hide-mobile { display: none !important; }
    .form-row { grid-template-columns: 1fr; }
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal { max-height: 92vh; border-radius: 16px 16px 0 0; }
}
