/**
 * Components Styles - Modal, Responsive, etc.
 */

/* ========== MODAL ========== */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.6) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
    padding: 20px;
    animation: fadeInModal 0.2s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white !important;
    border-radius: 12px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUpModal 0.2s ease-out;
    position: relative !important;
    z-index: 1000000 !important;
}

@keyframes slideUpModal {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-small {
    max-width: 400px;
}

.modal-medium {
    max-width: 550px;
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-title {
    font-size: 22px;
    color: var(--gray-900);
    font-weight: 600;
    letter-spacing: -0.5px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0;
    line-height: 1;
    transition: all 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.close-btn:hover {
    color: var(--gray-600);
    background: #f5f5f5;
    transform: rotate(90deg);
}

.modal-body {
    /* Modal content area */
    color: #555;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: var(--spacing-lg);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.modal-actions .btn {
    min-width: 120px;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.modal-actions .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
}

.modal-actions .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.modal-actions .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-actions .btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: none;
    cursor: pointer;
}

.modal-actions .btn-secondary:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

/* Modal Alert Styles */
.alert {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-lg);
    border-left: 4px solid transparent;
}

.alert-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left-color: #0c5460;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left-color: #155724;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-left-color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-left-color: #856404;
}

/* Modal Form Inputs */
.modal-body input[type="email"],
.modal-body input[type="password"],
.modal-body input[type="text"],
.modal-body select {
    width: 100%;
    padding: 12px 14px !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 6px !important;
    font-size: 14px !important;

    box-sizing: border-box !important;
    transition: all 0.3s ease !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    background: white !important;
    color: #333 !important;
}

.modal-body input[type="email"]:focus,
.modal-body input[type="password"]:focus,
.modal-body input[type="text"]:focus,
.modal-body select:focus {
    border-color: #667eea !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

.modal-body input[type="email"]::placeholder,
.modal-body input[type="password"]::placeholder,
.modal-body input[type="text"]::placeholder {
    color: #999 !important;
}

.modal-body label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

/* Forzar modal por encima de todo - Fix para Simple Browser */
body > .modal {
    position: fixed !important;
    z-index: 999999 !important;
}

/* Detail tabs for CRUD view modals */
.detail-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
}

.detail-tab {
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    cursor: pointer;
}

.detail-tab.is-active {
    background: #eef2ff;
    color: #3730a3;
    border-color: #a5b4fc;
}

.detail-panel {
    display: none;
}

.detail-panel.is-active {
    display: block;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.detail-item {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fcfcfd;
}

.detail-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.detail-value {
    display: block;
    font-size: 14px;
    color: #111827;
    word-break: break-word;
}

.detail-empty {
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    padding: 14px;
    font-size: 13px;
    color: #6b7280;
    background: #f9fafb;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        padding: 10px 15px;
    }
    
    .page-title {
        font-size: 18px;
    }
    
    .content-area {
        padding: 15px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .sidebar {
        width: 60px;
    }
    
    .main-content {
        margin-left: 60px;
    }
    
    .sidebar-header p,
    .menu-label {
        display: none;
    }
    
    .sidebar-header h2 {
        font-size: 16px;
    }
    
    .menu-item {
        justify-content: center;
        padding: 12px;
    }
    
    .user-email {
        display: none;
    }
}

/* ========== LOADING STATES ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}
