/* =============================================
   TRABGO PANEL — ESTILOS APP MOBILE-FIRST
   ============================================= */

:root {
    --bg: #f4f6f9;
    --card-bg: #fff;
    --text: #1a1a2e;
    --text-soft: #6b6794;
    --primary: #29235c;
    --primary-hover: #3b3280;
    --primary-light: #f0edff;
    --border: #e8e5f9;
    --accent: #00a19a;
    --success: #10b981;
    --success-bg: rgba(16,185,129,0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,0.1);
    --error: #ef4444;
    --error-bg: rgba(239,68,68,0.1);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --shadow: 0 2px 12px rgba(41,35,92,0.06);
    --shadow-lg: 0 8px 32px rgba(41,35,92,0.1);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --bottom-nav-height: 64px;
}

[data-theme="dark"] {
    --bg: #0c1a19;
    --card-bg: #142322;
    --text: #edf9f8;
    --text-soft: #8ba8a6;
    --primary: #00a19a;
    --primary-hover: #00c4bc;
    --primary-light: rgba(0,161,154,0.12);
    --border: rgba(0,161,154,0.1);
    --shadow: 0 2px 12px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.3);
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ========== LAYOUT PRINCIPAL ========== */
.panel-layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ========== TOP BAR (Móvil) ========== */
.panel-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
}

.panel-topbar .topbar-title {
    font-size: 18px;
    font-weight: 700;
}

.hamburger {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 8px;
    border-radius: var(--radius-xs);
    transition: background var(--transition);
}

.hamburger:active { background: var(--primary-light); }

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition);
}

.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ========== SIDEBAR ========== */
.panel-sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 150;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    will-change: transform;
}

.sidebar-logo {
    text-align: center;
    padding: 24px 20px 16px;
}

.sidebar-logo img { width: 100px; height: auto; }

.sidebar-nav {
    list-style: none;
    flex: 1;
    padding: 8px 12px;
    overflow-y: auto;
}

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-soft);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    user-select: none;
}

.sidebar-nav a:active { transform: scale(0.97); }

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

.sidebar-nav .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 16px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-soft); }

/* ========== OVERLAY (Móvil) ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 140;
    opacity: 0;
    transition: opacity var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ========== MAIN CONTENT ========== */
.panel-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px;
    max-width: 100%;
    transition: margin var(--transition);
}

/* ========== PAGE TRANSITIONS ========== */
.page-content {
    animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== CARDS ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    transition: box-shadow var(--transition);
}

.card:active { box-shadow: var(--shadow-lg); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title { font-size: 17px; font-weight: 600; }

/* ========== STATS GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    transition: transform var(--transition);
}

.stat-card:active { transform: scale(0.98); }

.stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-soft);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px; /* Evita zoom en iOS */
    color: var(--text);
    background: var(--bg);
    font-family: inherit;
    transition: all var(--transition);
    -webkit-appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea { min-height: 120px; resize: vertical; }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.96); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-danger { background: var(--error); color: #fff; }
.btn-sm { padding: 10px 16px; font-size: 13px; }
.btn-block { width: 100%; }

/* ========== BADGES ========== */
.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-info { background: var(--primary-light); color: var(--primary); }

/* ========== TABLES (Mobile: Cards) ========== */
.table-container {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: collapse; min-width: 600px; }

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-soft);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    position: sticky;
    top: 0;
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:active td { background: var(--primary-light); }

/* ========== ALERTS ========== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--error-bg); color: var(--error); }
.alert-info { background: var(--primary-light); color: var(--primary); }
.alert.visible { display: block; animation: fadeSlideIn 0.3s ease; }

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-soft);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { margin-bottom: 6px; color: var(--text); font-size: 16px; }
.empty-state p { font-size: 14px; }

/* ========== BOTTOM NAV (Móvil) ========== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
}

.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    min-width: 56px;
}

.bottom-nav a.active { color: var(--primary); }
.bottom-nav a:active { background: var(--primary-light); }

.bottom-nav .nav-icon { font-size: 20px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .panel-topbar { display: flex; }
    .bottom-nav { display: block; }

    .panel-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .panel-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.active {
        pointer-events: auto;
    }

    .panel-main {
        margin-left: 0 !important;
        padding: 16px;
        padding-top: calc(var(--topbar-height) + 16px);
        padding-bottom: calc(var(--bottom-nav-height) + 16px);
    }

    .stats-grid { grid-template-columns: 1fr 1fr; }
    .card { padding: 16px; }
}

@media (min-width: 769px) {
    .panel-topbar { display: none; }
    .bottom-nav { display: none; }
    .sidebar-overlay { display: none !important; }
    .panel-sidebar { transform: translateX(0) !important; }
}

/**Aviso cookies*/

/* Estilos del Banner de Cookies */
.cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid #e1e8ed;
    border-radius: 12px;
    padding: 20px;
    z-index: 99999;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.cookie-banner.hidden {
    opacity: 0;
    transform: translate(-50(), 30px);
    pointer-events: none;
}

.cookie-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.cookie-content p {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9rem;
    color: #4a5568;
    line-height: 1.5;
    text-align: left;
}

.cookie-buttons {
    display: flex;
    gap: 10px;
    white-space: nowrap;
}

.btn-cookie {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-cookie.accept {
    background: linear-gradient(135deg, #3498db, #2ecc71); /* Integración con tu identidad multicolor */
    color: white;
}

.btn-cookie.accept:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.btn-cookie.decline {
    background-color: #edf2f7;
    color: #718096;
}

.btn-cookie.decline:hover {
    background-color: #e2e8f0;
    color: #4a5568;
}

/* Responsivo para pantallas pequeñas */
@media (max-width: 768px) {
    .cookie-content {
        flex-direction: column;
        text-align: center;
    }
    .cookie-content p {
        text-align: center;
    }
    .cookie-buttons {
        width: 100%;
        justify-content: center;
    }
    .btn-cookie {
        flex: 1;
    }
}

#botonDarkMode{
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
}

/* Botón tema */
.theme-toggle {
  width: 45px; height: 45px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft);
  transition: border-color 0.2s, color 0.2s, background 0.3s;
  flex-shrink: 0;
  font-size: 24px;
}
.theme-toggle:hover { border-color: var(--teal); color: var(--teal); }
.theme-toggle svg { pointer-events: none; }


/* ========== PRELOADER ========== */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}
.page-loader.hidden { opacity: 0; pointer-events: none; }
.page-loader img { width: 80px; height: auto; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.05); }
}
.page-loader p { color: var(--text-soft); margin-top: 16px; font-size: 14px; }