/**
 * RUGAL — UI Enhancements v2.0
 * Mejoras globales de diseño e interactividad para todas las páginas
 */

/* ═══════════════════════════════════════════════
   VARIABLES GLOBALES
═══════════════════════════════════════════════ */
:root {
    --ugal-purple:      #7c3aed;
    --ugal-purple-dk:   #6d28d9;
    --ugal-purple-lt:   #a78bfa;
    --ugal-purple-soft: #ede9fe;
    --ugal-blue:        #3b82f6;
    --ugal-green:       #10b981;
    --ugal-yellow:      #f59e0b;
    --ugal-red:         #ef4444;
    --ugal-pink:        #ec4899;
    --ugal-shadow-glow: 0 8px 30px rgba(124,58,237,.25);
    --ugal-radius:      14px;
    --ugal-transition:  .25s cubic-bezier(.4,0,.2,1);
}

/* ═══════════════════════════════════════════════
   SCROLLBAR PERSONALIZADO
═══════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,58,237,.35); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,58,237,.6); }

/* ═══════════════════════════════════════════════
   SELECCIÓN DE TEXTO
═══════════════════════════════════════════════ */
::selection { background: rgba(124,58,237,.2); color: #4c1d95; }

/* ═══════════════════════════════════════════════
   ANIMACIÓN DE ENTRADA EN PÁGINA
═══════════════════════════════════════════════ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(.94); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes bounceIn {
    0%  { transform: scale(.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(.95); }
    100%{ transform: scale(1); opacity: 1; }
}
@keyframes ripple {
    from { transform: scale(0); opacity: .4; }
    to   { transform: scale(4); opacity: 0; }
}

/* Clases de animación */
.anim-fade-up   { animation: fadeInUp .5s ease both; }
.anim-fade      { animation: fadeIn .4s ease both; }
.anim-scale-in  { animation: scaleIn .4s ease both; }
.anim-slide-left{ animation: slideInLeft .4s ease both; }

/* Stagger delay para listas */
.anim-delay-1 { animation-delay: .05s; }
.anim-delay-2 { animation-delay: .1s; }
.anim-delay-3 { animation-delay: .15s; }
.anim-delay-4 { animation-delay: .2s; }
.anim-delay-5 { animation-delay: .25s; }

/* ═══════════════════════════════════════════════
   BOTONES MEJORADOS
═══════════════════════════════════════════════ */
.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: var(--ugal-radius);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--ugal-transition);
    text-decoration: none;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

/* Ripple effect en click */
.btn::after {
    content: '';
    position: absolute;
    width: 5px; height: 5px;
    background: rgba(255,255,255,.5);
    border-radius: 50%;
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
    transition: none;
}
.btn.ripple-active::after {
    animation: ripple .5s ease;
}

.btn-primary, .btn.btn-primary {
    background: linear-gradient(135deg, var(--ugal-purple) 0%, #a855f7 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(124,58,237,.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--ugal-shadow-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary, .btn.btn-secondary {
    background: var(--ugal-purple-soft);
    color: var(--ugal-purple);
    box-shadow: 0 2px 8px rgba(124,58,237,.1);
}
.btn-secondary:hover { background: #ddd6fe; transform: translateY(-1px); }

.btn-success { background: linear-gradient(135deg, #059669, #10b981); color: white; }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16,185,129,.3); }

.btn-danger { background: linear-gradient(135deg, #dc2626, #ef4444); color: white; }
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(239,68,68,.3); }

.btn-warning { background: linear-gradient(135deg, #d97706, #f59e0b); color: white; }
.btn-warning:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(245,158,11,.3); }

.btn-ghost {
    background: transparent;
    color: var(--ugal-purple);
    border: 2px solid var(--ugal-purple-lt);
}
.btn-ghost:hover {
    background: var(--ugal-purple-soft);
    border-color: var(--ugal-purple);
}

.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: var(--ugal-radius); }
.btn-xl { padding: 18px 36px; font-size: 17px; border-radius: 18px; }

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ═══════════════════════════════════════════════
   CARDS MEJORADAS
═══════════════════════════════════════════════ */
.card, .dashboard-card {
    border-radius: var(--ugal-radius);
    transition: transform var(--ugal-transition), box-shadow var(--ugal-transition);
}
.card:hover, .card.hoverable:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0,0,0,.12);
}

/* Card con borde de color arriba */
.card-accent-purple { border-top: 3px solid var(--ugal-purple); }
.card-accent-blue   { border-top: 3px solid var(--ugal-blue); }
.card-accent-green  { border-top: 3px solid var(--ugal-green); }
.card-accent-yellow { border-top: 3px solid var(--ugal-yellow); }

/* Glass card */
.card-glass {
    background: rgba(255,255,255,.07);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--ugal-radius);
}

/* ═══════════════════════════════════════════════
   INPUTS MEJORADOS
═══════════════════════════════════════════════ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
select,
textarea {
    transition: border-color var(--ugal-transition), box-shadow var(--ugal-transition);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: var(--ugal-purple) !important;
    box-shadow: 0 0 0 3px rgba(124,58,237,.12) !important;
    outline: none !important;
}

/* ═══════════════════════════════════════════════
   BADGES / CHIPS
═══════════════════════════════════════════════ */
.badge, .chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.badge-purple { background: var(--ugal-purple-soft); color: var(--ugal-purple); }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-pink   { background: #fce7f3; color: #9d174d; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ═══════════════════════════════════════════════
   TOAST NOTIFICATIONS (sistema global)
═══════════════════════════════════════════════ */
#rugal-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.rugal-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 14px;
    min-width: 280px;
    max-width: 380px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: all;
    animation: slideInLeft .35s ease, fadeOut .35s ease 3.5s forwards;
    box-shadow: 0 10px 30px rgba(0,0,0,.15);
    position: relative;
    overflow: hidden;
}
.rugal-toast::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    animation: shrinkBar 4s linear forwards;
    border-radius: 0 0 0 14px;
}
.rugal-toast.toast-success { background: #f0fdf4; border: 1.5px solid #86efac; color: #166534; }
.rugal-toast.toast-success::after { background: #22c55e; }
.rugal-toast.toast-error   { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; }
.rugal-toast.toast-error::after { background: #ef4444; }
.rugal-toast.toast-warning { background: #fffbeb; border: 1.5px solid #fcd34d; color: #92400e; }
.rugal-toast.toast-warning::after { background: #f59e0b; }
.rugal-toast.toast-info    { background: #eff6ff; border: 1.5px solid #93c5fd; color: #1e40af; }
.rugal-toast.toast-info::after { background: #3b82f6; }

.rugal-toast-icon { font-size: 18px; flex-shrink: 0; }
.rugal-toast-body { flex: 1; }
.rugal-toast-title { font-weight: 700; margin-bottom: 2px; }
.rugal-toast-close {
    background: none; border: none; cursor: pointer;
    font-size: 16px; opacity: .5; padding: 0;
    transition: opacity .2s;
    flex-shrink: 0;
}
.rugal-toast-close:hover { opacity: 1; }

@keyframes fadeOut { to { opacity: 0; transform: translateX(20px); } }
@keyframes shrinkBar { from { width: 100%; } to { width: 0%; } }

/* ═══════════════════════════════════════════════
   SIDEBAR MEJORADO
═══════════════════════════════════════════════ */
.sidebar {
    transition: transform .3s cubic-bezier(.4,0,.2,1), width .3s ease;
}

.sidebar .logo {
    padding: 28px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 8px;
    position: relative;
}

.sidebar .logo::after {
    content: '';
    position: absolute;
    bottom: 0; left: 20px; right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(124,58,237,.6), transparent);
}

.sidebar .menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    margin: 2px 10px;
    border-radius: 12px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 14px; font-weight: 500;
    transition: all .2s ease;
    position: relative;
}

.sidebar .menu-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    transition: transform .2s ease;
}

.sidebar .menu-item:hover {
    background: rgba(124,58,237,.18);
    color: white;
    padding-left: 26px;
}
.sidebar .menu-item:hover i { transform: scale(1.15); }

.sidebar .menu-item.active {
    background: linear-gradient(90deg, rgba(124,58,237,.35), rgba(124,58,237,.1));
    color: white;
    border-left: 3px solid var(--ugal-purple-lt);
    padding-left: 17px;
}
.sidebar .menu-item.active i { color: var(--ugal-purple-lt); }

.sidebar .section-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,.35);
    padding: 12px 20px 4px;
    margin-top: 4px;
}

.sidebar .menu-item.logout:hover {
    background: rgba(239,68,68,.15);
    color: #fca5a5;
}
.sidebar .menu-item.logout:hover i { color: #f87171; }

/* Submenu items */
.sidebar .submenu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px 9px 20px;
    margin: 1px 10px;
    border-radius: 10px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: all .2s;
}
.sidebar .submenu-item:hover {
    background: rgba(255,255,255,.06);
    color: white;
    padding-left: 26px;
}
.sidebar .submenu-item.active {
    background: rgba(124,58,237,.2);
    color: white;
}

/* Botón hamburguesa mejorado */
.hamburger-menu {
    position: fixed;
    top: 16px; left: 16px;
    z-index: 200;
    width: 42px; height: 42px;
    background: rgba(124,58,237,.9);
    border: none;
    border-radius: 12px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(124,58,237,.4);
    transition: all .2s;
}
.hamburger-menu:hover { background: var(--ugal-purple); transform: scale(1.05); }
.hamburger-menu span {
    display: block; width: 20px; height: 2px;
    background: white; border-radius: 2px;
    transition: all .3s;
}

@media (max-width: 768px) {
    .hamburger-menu { display: flex; }
}

/* ═══════════════════════════════════════════════
   SKELETON LOADING
═══════════════════════════════════════════════ */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}
.skeleton-text  { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-title { height: 22px; margin-bottom: 12px; width: 60%; border-radius: 4px; }
.skeleton-avatar{ width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.skeleton-btn   { height: 40px; border-radius: 10px; }

/* ═══════════════════════════════════════════════
   STATS CARDS (Dashboard)
═══════════════════════════════════════════════ */
.stat-widget {
    border-radius: var(--ugal-radius);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: transform var(--ugal-transition), box-shadow var(--ugal-transition);
    cursor: default;
}
.stat-widget:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(0,0,0,.15); }

.stat-widget .stat-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
    position: relative; z-index: 1;
}

.stat-widget .stat-value {
    font-size: 32px; font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    position: relative; z-index: 1;
}

.stat-widget .stat-label {
    font-size: 13px; font-weight: 500;
    opacity: .8;
    position: relative; z-index: 1;
}

/* Background icon decorator */
.stat-widget::before {
    content: attr(data-icon);
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: -10px; bottom: -15px;
    font-size: 90px;
    opacity: .08;
    line-height: 1;
}

/* ═══════════════════════════════════════════════
   PROGRESS BARS ANIMADAS
═══════════════════════════════════════════════ */
.progress-bar {
    height: 8px;
    background: rgba(0,0,0,.08);
    border-radius: 50px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 50px;
    background: linear-gradient(90deg, var(--ugal-purple), var(--ugal-purple-lt));
    transition: width 1s cubic-bezier(.4,0,.2,1);
    position: relative;
}
.progress-fill::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 30px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.4));
    animation: shimmer 1.5s infinite;
}

/* ═══════════════════════════════════════════════
   AVATAR / PHOTO COMPONENT
═══════════════════════════════════════════════ */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(124,58,237,.3);
    transition: border-color .2s, transform .2s;
}
.avatar:hover { border-color: var(--ugal-purple); transform: scale(1.05); }

.avatar-placeholder {
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ugal-purple), #a855f7);
    color: white;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ═══════════════════════════════════════════════
   MODAL MEJORADO
═══════════════════════════════════════════════ */
.modal-overlay {
    animation: fadeIn .25s ease;
}
.modal-content, .modal-box, [class*="modal-"] > .modal {
    animation: scaleIn .3s cubic-bezier(.34,1.56,.64,1);
}

/* ═══════════════════════════════════════════════
   TOOLTIPS
═══════════════════════════════════════════════ */
[data-tooltip] {
    position: relative;
    cursor: help;
}
[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(.9);
    background: #1e293b;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px; font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all .2s;
    z-index: 9999;
}
[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%; transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
    opacity: 0; transition: all .2s;
    pointer-events: none;
    z-index: 9999;
}
[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ═══════════════════════════════════════════════
   HEALTH SCORE INDICATOR
═══════════════════════════════════════════════ */
.health-ring {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.health-ring svg { transform: rotate(-90deg); }
.health-ring .ring-bg { fill: none; stroke: rgba(255,255,255,.1); }
.health-ring .ring-fill {
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s cubic-bezier(.4,0,.2,1);
}
.health-ring .ring-text {
    position: absolute;
    font-size: 22px; font-weight: 900;
}

/* ═══════════════════════════════════════════════
   ICON BOXES
═══════════════════════════════════════════════ */
.icon-box {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: transform .2s;
}
.icon-box:hover { transform: scale(1.1) rotate(-5deg); }

.icon-box-purple { background: rgba(124,58,237,.15); color: var(--ugal-purple); }
.icon-box-blue   { background: rgba(59,130,246,.15);  color: #3b82f6; }
.icon-box-green  { background: rgba(16,185,129,.15);  color: #10b981; }
.icon-box-yellow { background: rgba(245,158,11,.15);  color: #f59e0b; }
.icon-box-red    { background: rgba(239,68,68,.15);   color: #ef4444; }
.icon-box-pink   { background: rgba(236,72,153,.15);  color: #ec4899; }

/* ═══════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    opacity: .75;
}
.empty-state i {
    font-size: 56px;
    margin-bottom: 20px;
    opacity: .3;
}
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }

/* ═══════════════════════════════════════════════
   DIVIDER CON TEXTO
═══════════════════════════════════════════════ */
.divider-text {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: #94a3b8;
    font-size: 13px;
}
.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE HELPERS
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .hide-mobile   { display: none !important; }
    .show-mobile   { display: block !important; }
    .btn-xl        { padding: 14px 24px; font-size: 15px; }
    .stat-widget .stat-value { font-size: 26px; }
    #rugal-toast-container { top: auto; bottom: 20px; left: 16px; right: 16px; }
    .rugal-toast { min-width: 0; max-width: 100%; }
}
@media (min-width: 769px) {
    .show-mobile { display: none !important; }
}
