/* ============================================================
   common.css - Estilos comunes del sistema y de las aplicaciones
   Entidad: El Estilista Universal
   Misión: Proveer estilos compartidos para componentes del sistema (paneles, ventanas, toasts, etc.)
   Versión: 1.9.7 (Escudo Inexpugnable - Jack Frost)
   Masa: <200 líneas (Crucero - monitorizar para futura refactorización)
   Dependencias: Variables CSS definidas por cada tema.
   ============================================================ */

/* ========== UTILIDADES DE INTERACCIÓN (Hover + Focus) ========== */
/* Clase "x" para elementos interactivos */
.x:hover,
.x:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  background: var(--primary);
  color: var(--text-alt);
  transform: var(--scale); /* Asegúrate de definir --scale en tu tema (ej: scale(1.02)) */
}

/* Focus visible para elementos interactivos comunes (sin clase x) */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.wm-btn:focus-visible,
.wm-close-btn:focus-visible,
.style-close-btn:focus-visible,
.bubble-menu-option:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* === COMPONENTES DEL SISTEMA === */

/* Scroll accesible */
::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}
::-webkit-scrollbar-track {
    background: var(--bg-03);
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 8px;
    min-height: 48px;
    border: 2px solid var(--bg-03);
}
::-webkit-scrollbar-thumb:hover,
::-webkit-scrollbar-thumb:focus-visible {
    background: var(--primary-hover);
}
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-hover) var(--bg-03);
}

/* Panel superior */
.top-panel {
    backdrop-filter: var(--blur-effect);
    color: var(--text);
}
.dynamic-slider {
    background: var(--bg-06);
    border-radius: var(--radius-pill);
    padding: 4px 12px;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
}

/* Botón de menú de ventana */
.win-menu-btn {
    background: var(--bg-03);
    border: 1px solid var(--border);
    border-radius: 30px;
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.1s;
}

/* Botón Avalancha */
.avalanche-trigger {
    background: var(--bg-03);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    touch-action: manipulation;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.avalanche-trigger::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    background: transparent;
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
}
.avalanche-trigger:active {
    background: rgba(0, 102, 204, 0.3);
    border-radius: 50%;
    transform: scale(0.96);
    transition: background 0.05s, transform 0.05s;
}
.avalanche-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 50%;
    pointer-events: none;
}

/* Ventanas flotantes */
.floating-window {
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur-effect);
}
.window-content {
    color: var(--text);
}
.window-inactive-overlay {
    background: var(--bg-06);
}

/* Panel de gestión de ventanas */
.window-manager-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-window);
    min-width: 320px;
    max-width: 500px;
    width: 90vw;
    backdrop-filter: var(--blur-effect);
    display: flex;
    flex-direction: column;
}
.wm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    font-weight: bold;
    color: var(--text);
}
.wm-close-btn {
    background: var(--bg);
    border-radius: var(--radius-pill);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
}
.wm-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 60vh;
    overflow-y: auto;
}
.wm-item {
    padding: 12px 16px;
    color: var(--text);
}
.wm-item-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.wm-item-icon {
    font-size: 1.2rem;
}
.wm-item-name {
    font-weight: 500;
    flex: 1;
}
.wm-item-minimized {
    font-size: 0.7rem;
    background: var(--bg-03);
    padding: 2px 6px;
    border-radius: 12px;
    color: var(--text-muted);
}
.wm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.wm-btn {
    background: var(--bg-03);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 4px 10px;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.05s linear;
}
.wm-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
}
.wm-separator {
    margin: 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* Panel de estilo */
.window-style-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-window);
    backdrop-filter: var(--blur-effect);
    padding: 16px;
    width: 260px;
}
.style-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: bold;
}
.style-control {
    margin-bottom: 12px;
}
.style-control label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 4px;
}
.style-control input {
    width: 100%;
}
.style-reset-btn {
    background: var(--bg-03);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 12px;
    cursor: pointer;
    width: 100%;
}
.style-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

/* Menú contextual */
.window-bubble-menu {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    backdrop-filter: var(--blur-effect);
    padding: 4px 0;
    min-width: 160px;
}
.bubble-menu-option {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.05s;
    color: var(--text);
}

/* Notificaciones toast */
#mizu-notification-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 20000000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.mizu-toast {
    background: var(--bg);
    border-left: 4px solid var(--primary);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 0.9rem;
    pointer-events: auto;
    backdrop-filter: var(--blur-effect);
    max-width: 400px;
    margin: 0 auto;
}
.mizu-toast-success {
    border-left-color: var(--success);
}
.mizu-toast-error {
    border-left-color: var(--error);
}
.mizu-toast-info {
    border-left-color: var(--primary);
}

/* Barra de carga */
.loading-bar {
    background: var(--primary);
    height: 3px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive general */
@media (max-width: 600px) {
    .window-manager-panel {
        width: 95vw;
        min-width: unset;
    }
    .wm-actions {
        gap: 6px;
    }
    .wm-btn {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}

/* ========== ESTILOS DE APLICACIONES ========== */

.app-root {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: visible;
}
.window-maximized .app-root {
    margin-top: 60px;
    height: calc(100% - 60px);
}
@media (orientation: portrait) {
    .window-maximized .app-root {
        margin-top: 70px;
        height: calc(100%);
    }
}
.app-title {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-weight: 600;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}
.app-subtitle {
    font-size: clamp(1rem, 4vw, 1.4rem);
    font-weight: 500;
    margin: 0.75rem 0 0.5rem;
}
.app-card {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-window);
    max-width: 100%;
    box-sizing: border-box;
}
.app-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.app-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.app-table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
}
.app-table th,
.app-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.app-form-group {
    margin-bottom: 1rem;
}
.app-form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}
.app-form-group input,
.app-form-group select,
.app-form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    box-sizing: border-box;
}
.app-message {
    margin: 1rem 0;
    padding: 0.75rem;
    text-align: center;
    background: var(--bg-03);
    border-radius: 4px;
}
@media (max-width: 600px) {
    .app-root {
        padding: 12px;
    }
    .app-card {
        padding: 0.75rem;
    }
    .app-title {
        font-size: 1.2rem;
    }
}

/* Botones base */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    border: 3px solid var(--border);
    border-radius: var(--radius-pill);
    transition: background 0.1s, transform 0.05s, opacity 0.1s;
    background: var(--bg);
    color: var(--text);
}
.btn:active {
    transform: scale(0.96);
    color: var(--text-alt);
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-secondary {
    background: var(--bg-03);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-danger {
    background: #e02424;
    color: white;
}
.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
}
.btn-lg {
    padding: 0.8rem 1.6rem;
    font-size: 1rem;
}

.window-content-padded {
    padding-top: 60px;
}
@media (orientation: portrait) {
    .window-content-padded {
        padding-top: 70px;
    }
}
