/**
 * Estilos para componentes reutilizables
 * Toast, Modal, Tooltips, etc.
 */

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    max-width: 500px;
    transform: translateX(400px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.toast-show {
    transform: translateX(0);
    opacity: 1;
}

.toast-hide {
    transform: translateX(400px);
    opacity: 0;
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.toast-close:hover {
    background: var(--bg-secondary);
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-error {
    border-left: 4px solid var(--danger-color);
}

.toast-warning {
    border-left: 4px solid var(--warning-color);
}

.toast-info {
    border-left: 4px solid var(--info-color);
}

/* ==========================================
   MODAL STYLES - SISTEMA UNIFICADO
   ========================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
    position: relative;
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
    font-weight: 600;
}

.modal-close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    background: none;
    border: none;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    font-weight: bold;
}

.modal-close:hover {
    color: var(--danger-color);
    background: var(--bg-primary);
    transform: scale(1.1);
}

.modal-close:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: var(--bg-secondary);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* Modal grande para formularios complejos */
.modal-large .modal-content {
    max-width: 1000px;
    width: 95%;
}

/* Modal pequeño para confirmaciones */
.modal-small .modal-content {
    max-width: 400px;
}

/* Animaciones de entrada y salida */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Estados de carga en modales */
.modal-loading {
    position: relative;
}

.modal-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.modal-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ==========================================
   TOOLTIP STYLES
   ========================================== */

.tooltip {
    position: absolute;
    background: var(--bg-darker);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 10001;
    pointer-events: none;
    animation: tooltipFadeIn 0.2s ease;
}

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

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--bg-darker);
}

/* ==========================================
   LOADING SPINNER
   ========================================== */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

/* ==========================================
   DROPDOWN MENU
   ========================================== */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    display: none;
    z-index: 1000;
}

.dropdown-menu.show {
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: var(--bg-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* ==========================================
   COMPONENTE CRUD ACTIONS
   ========================================== */

/* Contenedor de acciones CRUD */
.acciones {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    padding: 0.25rem;
    min-width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Botones de acción CRUD */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    flex-shrink: 0;
    position: relative;
}

.btn-icon:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-icon:active {
    transform: translateY(0);
}

/* Estados específicos de botones CRUD */
.btn-ver:hover {
    background: var(--info-color);
    color: white;
}

.btn-descargar:hover {
    background: var(--success-color);
    color: white;
}

.btn-editar:hover {
    background: var(--warning-color);
    color: white;
}

.btn-eliminar:hover {
    background: var(--danger-color);
    color: white;
}

/* Indicador de sin archivo */
.no-archivo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    color: var(--text-light);
    font-size: 1.2rem;
    opacity: 0.6;
    cursor: help;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

/* Tooltip para botones */
.btn-icon[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-darker);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

.btn-icon[title]:hover::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--bg-darker);
    z-index: 1000;
    pointer-events: none;
}

/* Estados de carga para botones */
.btn-icon.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-icon.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Botones deshabilitados */
.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Responsive para acciones CRUD */
@media (max-width: 768px) {
    .acciones {
        gap: 0.5rem;
        padding: 0.25rem;
        min-width: 150px;
    }
    
    .btn-icon {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }
    
    .no-archivo {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .acciones {
        flex-wrap: wrap;
        gap: 0.25rem;
        justify-content: center;
    }
    
    .btn-icon {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.9rem;
    }
}

/* Responsive para modales */
@media (max-width: 768px) {
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--border-radius);
    }
    
    .modal-large .modal-content {
        max-width: 100%;
        width: 100%;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-header h2 {
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer button {
        width: 100%;
    }
}

/* ==========================================
   SISTEMA DE ALERTAS Y CONFIRMACIONES
   ========================================== */

.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.alert-overlay.show {
    opacity: 1;
    visibility: visible;
}

.alert-dialog {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 450px;
    width: 100%;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.alert-overlay.show .alert-dialog {
    transform: scale(1) translateY(0);
}

.alert-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.alert-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
}

.alert-icon {
    font-size: 1.75rem;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* Iconos por tipo */
.alert-icon-question {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
}

.alert-icon-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.alert-icon-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.alert-icon-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.alert-icon-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.alert-icon-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

.alert-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.alert-body {
    padding: 1.5rem;
}

.alert-message {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
}

.alert-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.alert-simple .alert-footer {
    justify-content: center;
}

.alert-btn {
    padding: 0.625rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.alert-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.alert-btn-cancel {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.alert-btn-cancel:hover {
    background: var(--bg-secondary);
    border-color: var(--text-light);
}

.alert-btn-confirm {
    background: var(--primary-color);
    color: white;
}

.alert-btn-confirm:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.alert-btn-primary {
    background: var(--primary-color);
    color: white;
}

.alert-btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.alert-btn-success {
    background: var(--success-color);
    color: white;
}

.alert-btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.alert-btn-danger {
    background: var(--danger-color);
    color: white;
}

.alert-btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.alert-btn-warning {
    background: var(--warning-color);
    color: white;
}

.alert-btn-warning:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Responsive para alertas */
@media (max-width: 480px) {
    .alert-dialog {
        max-width: 100%;
        margin: 0.5rem;
    }

    .alert-header {
        padding: 1rem;
        flex-direction: column;
        text-align: center;
    }

    .alert-body {
        padding: 1rem;
    }

    .alert-footer {
        padding: 1rem;
        flex-direction: column;
    }

    .alert-btn {
        width: 100%;
    }
}

