/* ---
   STYLE-DASHBOARD.CSS
   El CSS para el Centro de Mando SasoTech
--- */

/* --- 1. Reseteo y Variables Globales --- */
:root {
    --color-primario: #007bff;
    --color-secundario: #00c6ff;
    --color-alerta: #ffc107;
    --color-alerta-grave: #dc3545;
    
    --color-texto-principal: #ffffff;
    --color-texto-secundario: #e0e0e0;
    --color-fondo-app: #0f0c29;
    --color-fondo-gradiente: linear-gradient(to right, #24243e, #302b63, #0f0c29);
    
    /* El "Efecto Cristal" (Glassmorphism) */
    --color-fondo-tarjeta: rgba(30, 30, 60, 0.4);
    --color-borde: rgba(255, 255, 255, 0.15);
    
    --font-principal: 'Poppins', sans-serif;
    
    --sidebar-width-collapsed: 80px;
    --sidebar-width-expanded: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-principal);
    background: var(--color-fondo-app);
    background: var(--color-fondo-gradiente);
    color: var(--color-texto-principal);
    display: flex;
    overflow-x: hidden;
}

/* --- 2. Sidebar (Menú Lateral) --- */
.sidebar {
    width: var(--sidebar-width-collapsed);
    height: 100vh;
    background: var(--color-fondo-tarjeta);
    border-right: 1px solid var(--color-borde);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    transition: width 0.3s ease;
    overflow: hidden;
    z-index: 100;
}

.sidebar:hover {
    width: var(--sidebar-width-expanded);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center; /* Centrado por defecto */
    margin-bottom: 2rem;
    padding: 0 1.5rem;
    position: relative;
    height: 40px;
}

.logo-icon {
    font-size: 2rem;
    color: var(--color-primario);
    transition: all 0.3s ease;
}

.sidebar-logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    opacity: 0;
    position: absolute;
    left: 80px; /* Fuera de la vista */
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.sidebar:hover .sidebar-header {
    justify-content: flex-start;
}
.sidebar:hover .logo-icon {
    transform: rotate(-15deg); /* Efecto cool */
}
.sidebar:hover .sidebar-logo-text {
    opacity: 1;
}

.sidebar-menu {
    list-style: none;
    flex-grow: 1;
}

.menu-item {
    width: 100%;
    margin-bottom: 0.5rem;
}

.menu-item a {
    display: flex;
    align-items: center;
    padding: 1rem 1.7rem;
    color: var(--color-texto-secundario);
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap; /* Evita que el texto se parta */
}

.menu-item a i {
    font-size: 1.5rem;
    min-width: 46px; /* Mantiene el icono alineado */
    text-align: center;
}

.menu-text {
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-left: 1rem;
    font-weight: 500;
}

.sidebar:hover .menu-text {
    opacity: 1;
}

.menu-item a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-texto-principal);
}

.menu-item.active a {
    color: var(--color-primario);
    border-left: 4px solid var(--color-primario);
    background: rgba(0, 123, 255, 0.1);
    padding-left: calc(1.7rem - 4px); /* Compensa el borde */
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--color-borde);
}
.sidebar-footer .menu-item a:hover {
    color: var(--color-alerta-grave);
}


/* --- 3. Contenido Principal --- */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width-collapsed);
    padding: 2rem;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

/* El contenido principal se expande cuando el menú está colapsado */
.sidebar:hover ~ .main-content {
    margin-left: var(--sidebar-width-expanded);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.main-header h1 {
    font-size: 2.5rem;
    font-weight: 600;
}

.header-user {
    display: flex;
    align-items: center;
    font-size: 1rem;
}
.header-user i {
    font-size: 2rem;
    margin-left: 1rem;
    color: var(--color-texto-secundario);
}


/* --- 4. HUD Grid (El Dashboard) --- */
.glass-card {
    background: var(--color-fondo-tarjeta);
    border: 1px solid var(--color-borde);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1.5rem;
}

.hud-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.hud-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.hud-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* (A) Métrica Principal (Gráfico Radial) */
.main-metric {
    /* Ocupa más espacio */
    grid-column: span 1; /* Por defecto */
    min-height: 350px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.metric-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-texto-secundario);
}

.radial-progress {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 1rem 0;
    
    /* ¡LA MAGIA! Gráfico cónico con CSS */
    background: conic-gradient(
        var(--color-secundario) calc(var(--progress) * 3.6deg),
        var(--color-borde) calc(var(--progress) * 3.6deg)
    );
    animation: progress-load 1.5s ease-out;
}

.radial-center {
    width: 170px;
    height: 170px;
    background: var(--color-fondo-app);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.radial-percentage {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-texto-principal);
}
.radial-subtext {
    font-size: 0.9rem;
    color: var(--color-texto-secundario);
}

.metric-summary {
    font-size: 1.2rem;
    font-weight: 500;
}
.metric-summary span {
    font-weight: 700;
    color: var(--color-secundario);
}

/* (B) Alerta de Vencimiento */
.next-renewal-alert {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.4), rgba(255, 193, 7, 0.3));
    border-color: var(--color-alerta-grave);
    text-align: center;
}
.next-renewal-alert h3 {
    font-size: 1.1rem;
    color: var(--color-texto-secundario);
    font-weight: 500;
}
.next-renewal-alert h2 {
    font-size: 3rem;
    color: var(--color-alerta);
    margin: 0.5rem 0;
}
.next-renewal-alert p {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
}
.next-renewal-alert span {
    font-size: 0.9rem;
    color: var(--color-texto-secundario);
}
.alert-icon {
    font-size: 1.5rem;
    color: var(--color-alerta);
    margin-bottom: 0.5rem;
}

/* (C y D) Tarjetas de Stats */
.stat-card {
    display: flex;
    flex-direction: column;
}
.card-icon {
    font-size: 1.5rem;
    color: var(--color-primario);
    margin-bottom: 1rem;
}
.stat-card h3 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-texto-secundario);
}
.stat-card h2 {
    font-size: 3rem;
    margin: 0.5rem 0;
    color: #fff;
    flex-grow: 1; /* Empuja el link abajo */
}
.card-link {
    color: var(--color-primario);
    text-decoration: none;
    font-weight: 500;
}
.card-link:hover {
    text-decoration: underline;
}

/* --- 5. Ticker de Alertas --- */
.alerts-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    overflow: hidden;
}
.alerts-section h4 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}
.alerts-section h4 i {
    color: var(--color-alerta);
}

.alerts-ticker {
    width: 100%;
    white-space: nowrap; /* Clave para el ticker */
}
.ticker-wrapper {
    display: inline-block;
    padding-left: 100%; /* Inicia fuera de la pantalla */
    animation: ticker-scroll 30s linear infinite;
}
.ticker-item {
    display: inline-flex;
    align-items: center;
    margin-right: 3rem;
    font-size: 1rem;
    color: var(--color-texto-secundario);
}
.ticker-item strong {
    color: #fff;
    margin: 0 0.4rem;
}
.ticker-item [class*="tag-"] {
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.7rem;
    color: #000;
}
.tag-dominio { background: var(--color-primario); color: #fff; }
.tag-hosting { background: var(--color-secundario); }
.tag-garantía { background: var(--color-alerta); }


/* --- 6. Animaciones y Responsividad --- */

/* Animación de carga del gráfico */
@keyframes progress-load {
    from { --progress: 0; }
    to { /* El valor se setea inline */ }
}

/* Animación del Ticker */
@keyframes ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* Para dispositivos medianos (tablets) */
@media (min-width: 992px) {
    .main-metric {
        /* En pantallas grandes, el gráfico es el centro */
        grid-column: span 2;
        grid-row: span 2;
    }
    .next-renewal-alert {
        grid-column: span 2;
    }
    .stat-card {
        grid-column: span 1;
    }
    .hud-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Para dispositivos móviles */
@media (max-width: 768px) {
    body { flex-direction: column; }
    .main-content {
        margin-left: 0;
        /* Hacemos espacio para un menú inferior (no implementado aquí) */
        padding: 1rem;
        padding-bottom: 100px;
    }
    .sidebar {
        /* En móvil, el sidebar podría ser horizontal abajo o un toggle */
        /* Por simplicidad, lo ocultamos */
        display: none; 
    }
    .main-header h1 {
        font-size: 1.8rem;
    }
    .header-user span {
        display: none; /* Oculta el nombre en móvil */
    }
    .hud-grid {
        grid-template-columns: 1fr; /* Una columna */
    }
    .main-metric {
        grid-column: span 1;
        grid-row: span 1;
    }
    .next-renewal-alert {
        grid-column: span 1;
    }
}