/* ========================================
   VARIABLES GLOBALES Y RESET
   ======================================== */

:root {
    /* Colores principales */
    --primary: #641f70;
    --primary-dark: #4a1755;
    --primary-light: #7d2e87;
    --secondary: #17a2b8;
    --accent: #ffc107;
    
    /* Colores de fondo */
    --bg: #ffffff;
    --surface: #f8f9fa;
    --card-bg: #ffffff;
    
    /* Colores de texto */
    --text: #212529;
    --text-secondary: #6c757d;
    --text-muted: #95a5a6;
    
    /* Bordes y sombras */
    --border: #dee2e6;
    --shadow: rgba(100, 31, 112, 0.1);
    --shadow-hover: rgba(100, 31, 112, 0.2);
    
    /* Estados */
    --success: #28a745;
    --error: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    
    /* Gradientes */
    --gradient-bg: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    --gradient-hero: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--secondary) 100%);
    
    /* Transiciones */
    --transition: all 0.3s ease;
}

/* Tema oscuro */
[data-theme="dark"] {
    --bg: #1a1a1a;
    --surface: #2d2d2d;
    --card-bg: #252525;
    --text: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #7f8c8d;
    --border: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
}

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: var(--transition);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========================================
   UTILIDADES GENERALES
   ======================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mt-40 { margin-top: 40px; }

.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }
.mb-40 { margin-bottom: 40px; }

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* ========================================
   BOTONES
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(100, 31, 112, 0.4);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #138496;
    transform: translateY(-2px);
}

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

.btn-success:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
}

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

.btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
    display: flex;
}

/* ========================================
   FORMULARIOS
   ======================================== */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.form-label.required::after {
    content: ' *';
    color: var(--error);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(100, 31, 112, 0.1);
}

.form-control:disabled {
    background: var(--surface);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-control.error {
    border-color: var(--error);
}

.form-control.success {
    border-color: var(--success);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
}

.form-error {
    color: var(--error);
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.form-error.show {
    display: block;
}

.form-help {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 5px;
}

/* Input con icono */
.input-group {
    position: relative;
}

.input-group .form-control {
    padding-left: 45px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 18px;
}

/* Checkbox y Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.form-check label {
    cursor: pointer;
    font-weight: normal;
}

/* ========================================
   ALERTAS Y NOTIFICACIONES
   ======================================== */

.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

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

.alert i {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--error);
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid var(--info);
}

.alert-dismissible {
    padding-right: 45px;
    position: relative;
}

.alert-close {
    position: absolute;
    right: 15px;
    top: 15px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
}

.alert-close:hover {
    opacity: 1;
}

/* ========================================
   CARDS
   ======================================== */

.card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 20px var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 8px 30px var(--shadow-hover);
    transform: translateY(-2px);
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.card-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.card-body {
    margin-bottom: 20px;
}

.card-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ========================================
   MODALES
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 20px;
}

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

.modal {
    background: var(--card-bg);
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    padding: 25px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--surface);
    color: var(--text);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ========================================
   LOADING Y SPINNERS
   ======================================== */

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

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.loading-text {
    margin-top: 15px;
    color: white;
    font-weight: 600;
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

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

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

.badge-danger {
    background: var(--error);
    color: white;
}

.badge-warning {
    background: var(--warning);
    color: #333;
}

.badge-info {
    background: var(--info);
    color: white;
}

.badge-secondary {
    background: var(--text-secondary);
    color: white;
}

/* ========================================
   TABLAS
   ======================================== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
}

.table thead {
    background: var(--surface);
}

.table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.table tbody tr:hover {
    background: var(--surface);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ========================================
   PAGINACIÓN
   ======================================== */

.pagination {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
}

.pagination button {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .modal {
        max-width: 100%;
        margin: 20px;
    }

    .card {
        padding: 20px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 13px;
    }

    .table {
        font-size: 13px;
    }

    .table th,
    .table td {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .btn-block-mobile {
        width: 100%;
        display: flex;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ========================================
   ANIMACIONES EXTRAS
   ======================================== */

.fade-in {
    animation: fadeIn 0.5s ease;
}

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

.slide-up {
    animation: slideUp 0.5s ease;
}

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

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}
