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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 { font-size: 24px; display: flex; align-items: center; gap: 15px; }

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary { background: #4CAF50; color: white; }
.btn-primary:hover { background: #45a049; transform: translateY(-2px); }
.btn-secondary { background: #2196F3; color: white; }
.btn-danger { background: #f44336; color: white; }
.btn-warning { background: #ff9800; color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Botón Volver al Dashboard */
.btn-back {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.content { padding: 30px; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon { font-size: 36px; opacity: 0.9; }
.stat-info h3 { font-size: 32px; margin-bottom: 5px; }
.stat-info p { opacity: 0.9; font-size: 14px; }

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #d4edda; color: #155724; border-left: 4px solid #28a745; }
.alert-error { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }

.search-section {
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
}

.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead { background: #f8f9fa; }

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.2s;
}

th:hover {
    background: #e9ecef;
}

th.sortable::after {
    content: ' ⇅';
    opacity: 0.3;
    font-size: 12px;
    margin-left: 5px;
}

th.sort-asc::after {
    content: ' ▲';
    opacity: 1;
    color: #2a5298;
}

th.sort-desc::after {
    content: ' ▼';
    opacity: 1;
    color: #2a5298;
}

td {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
}

tr:hover { background: #f8f9fa; }

.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    white-space: nowrap;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

.actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.btn-action {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-edit {
    background: #2196F3;
}

.btn-edit:hover {
    background: #1976D2;
}

.btn-toggle {
    background: #ff9800;
}

.btn-toggle:hover {
    background: #f57c00;
}

.btn-delete {
    background: #f44336;
}

.btn-delete:hover {
    background: #d32f2f;
}

.btn-action i {
    font-size: 16px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

.modal[style*="display: block"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

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

.modal.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
    animation: slideDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    margin: auto;
}

.modal-header {
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    color: white;
    padding: 30px 35px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    position: relative;
    overflow: hidden;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(66, 153, 225, 0.15) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h2::before {
    content: '⚙';
    font-size: 20px;
    opacity: 0.9;
    color: #4299e1;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
}

.close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-body {
    padding: 35px;
    max-height: calc(90vh - 220px);
    overflow-y: auto;
    background: #fafbfc;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.form-group {
    margin-bottom: 24px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.form-group label span {
    color: #e74c3c;
    margin-left: 2px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    color: #2c3e50;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #cbd5e0;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2c5364;
    box-shadow: 0 0 0 4px rgba(44, 83, 100, 0.15);
    background: white;
}

.form-group small {
    display: block;
    margin-top: 8px;
    color: #718096;
    font-size: 13px;
    font-style: italic;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    line-height: 1.6;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.modal-footer {
    padding: 25px 35px;
    background: white;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    border-top: 1px solid #e1e8ed;
}

.modal-footer .btn {
    padding: 14px 40px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.modal-footer .btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.modal-footer .btn:hover::before {
    width: 300px;
    height: 300px;
}

.modal-footer .btn-primary {
    background: linear-gradient(135deg, #0f2027 0%, #2c5364 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(44, 83, 100, 0.4);
    position: relative;
}

.modal-footer .btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(44, 83, 100, 0.5);
    background: linear-gradient(135deg, #203a43 0%, #2c5364 100%);
}

.modal-footer .btn-primary:active {
    transform: translateY(-1px);
}

.modal-footer .btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-footer .btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-modal:hover { background: rgba(255,255,255,0.2); }

@media (max-width: 768px) {
    .header { flex-direction: column; align-items: stretch; }
    .header h1 { font-size: 20px; }

    /* Botones del header en móvil */
    .header > div {
        flex-direction: column;
        width: 100%;
    }

    .header .btn,
    .header .btn-back {
        width: 100%;
        justify-content: center;
    }

    .stats { grid-template-columns: 1fr; }
    table { font-size: 12px; }
    th, td { padding: 8px; }

    .modal-content {
        border-radius: 20px 20px 0 0;
        max-height: 95vh;
        margin-top: auto;
    }

    .modal-body {
        padding: 25px;
    }

    .modal-footer {
        padding: 20px 25px;
        flex-direction: column;
    }

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

/* Efectos de input mejorados */
.form-group {
    position: relative;
}

.form-group input:not(:placeholder-shown) ~ label,
.form-group textarea:not(:placeholder-shown) ~ label,
.form-group select:not([value=""]) ~ label {
    color: #2c5364;
}

/* Animación del botón Guardar */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Estilo para campos requeridos */
.form-group input:required,
.form-group select:required {
    background-image: none;
}

.form-group input:valid {
    border-color: #48bb78;
}

.form-group input:invalid:not(:placeholder-shown) {
    border-color: #f56565;
}

/* Loader para cuando se envía el formulario */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

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

/* Mejora visual de selects */
.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232c5364' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

/* Efecto de focus en inputs */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    transform: translateY(-1px);
}
