/* Componentes Reutilizables */

/* Contenedores */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-fluid {
    width: 100%;
    padding: 0 1rem;
}

/* Grid */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.75rem;
}

.col {
    flex: 1;
    padding: 0 0.75rem;
}

.col-4 {
    flex: 0 0 33.333333%;
    max-width: 33.333333%;
    padding: 0 0.75rem;
}

.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 0 0.75rem;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 0.75rem;
}

/* Botones */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.5;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background-color: #1e3a8a;
    color: white;
    border-color: #1e3a8a;
}

.btn-primary:hover {
    background-color: #1e40af;
    border-color: #1e40af;
}

.btn-outline-primary {
    background-color: transparent;
    color: #1e3a8a;
    border-color: #1e3a8a;
}

.btn-outline-primary:hover {
    background-color: #1e3a8a;
    color: white;
}

.btn-success {
    background-color: #198754;
    color: white;
    border-color: #198754;
}

.btn-success:hover {
    background-color: #157347;
    border-color: #146c43;
}

.btn-info {
    background-color: #0dcaf0;
    color: #000;
    border-color: #0dcaf0;
}

.btn-info:hover {
    background-color: #31d2f2;
    border-color: #25cff2;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Formularios */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #212529;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Estilos para validación de formularios */
.input-validation-error {
    border-color: #dc3545 !important;
}

.input-validation-error:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

.field-validation-error {
    color: #dc3545;
    font-size: 0.875rem;
    display: block;
    margin-top: 0.25rem;
}

.field-validation-valid {
    display: none;
}

.form-select {
    display: block;
    width: 100%;
    padding: 0.75rem 2.25rem 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

.form-select:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.5rem;
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    margin-bottom: 0;
}

.input-group {
    display: flex;
    width: 100%;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-right: 0;
    border-radius: 0.375rem 0 0 0.375rem;
    color: #495057;
}

.input-group .form-control {
    border-radius: 0 0.375rem 0.375rem 0;
}

/* Alertas */
.alert {
    padding: 1rem 1.25rem;
    margin: 1rem;
    border-radius: 0.375rem;
    position: relative;
}

.alert-success {
    background-color: #d1e7dd;
    border: 1px solid #badbcc;
    color: #0f5132;
}

.alert-danger {
    background-color: #f8d7da;
    border: 1px solid #f5c2c7;
    color: #842029;
}

.alert-dismissible {
    padding-right: 3rem;
}

.btn-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    padding: 0.5rem;
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: #000;
    opacity: 0.5;
    cursor: pointer;
}

.btn-close:hover {
    opacity: 0.75;
}

.btn-close::before {
    content: "×";
}

/* Tarjetas */
.card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    height: fit-content;
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.card-text {
    color: #6c757d;
    margin-bottom: 1rem;
}

/* Utilidades */
.text-center {
    text-align: center;
}

.text-muted {
    color: #6c757d !important;
}

.text-primary {
    color: #0d6efd !important;
}

.text-success {
    color: #198754 !important;
}

.text-danger {
    color: #dc3545 !important;
}

.text-small {
    font-size: 0.875rem;
}

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

.p-4 { padding: 1.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }

.rounded { border-radius: 0.375rem !important; }
.shadow-sm { box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; }

.d-flex {
    display: flex !important;
}

.flex-column {
    flex-direction: column !important;
}

.justify-content-center {
    justify-content: center !important;
}

.align-items-center {
    align-items: center !important;
}

.gap-2 {
    gap: 0.5rem !important;
}

.gap-3 {
    gap: 1rem !important;
}

.gap-4 {
    gap: 1.5rem !important;
}

.h-100 {
    height: 100% !important;
}

.bg-white {
    background-color: white !important;
}

/* Tipografía */
.display-3 {
    font-size: 3rem;
    font-weight: 300;
    line-height: 1.2;
}

.display-4 {
    font-size: 2.5rem;
    font-weight: 300;
    line-height: 1.2;
}

.display-5 {
    font-size: 2rem;
    font-weight: 300;
    line-height: 1.2;
}

.lead {
    font-size: 1.25rem;
    font-weight: 300;
}

.fw-bold {
    font-weight: 700 !important;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: 500;
    line-height: 1.2;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

/* Ejercicios Específicos */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.page-header h1 {
    margin-bottom: 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5c636a;
    border-color: #565e64;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-danger:hover {
    background-color: #bb2d3b;
    border-color: #b02a37;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Grid para ejercicios */
.grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.grid-sidebar {
    grid-template-columns: 1fr 350px;
}

/* Cards de ejercicios */
.ejercicio-card {
    padding: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.ejercicio-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.ejercicio-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.ejercicio-header h3 {
    margin: 0;
    font-size: 1.1rem;
    flex: 1;
}

.ejercicio-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
}

.badge-success {
    background-color: #d1e7dd;
    color: #0f5132;
}

.badge-secondary {
    background-color: #e2e3e5;
    color: #41464b;
}

.badge-principiante {
    background-color: #cfe2ff;
    color: #084298;
}

.badge-intermedio {
    background-color: #fff3cd;
    color: #997404;
}

.badge-avanzado {
    background-color: #f8d7da;
    color: #842029;
}

.badge-info {
    background-color: #cff4fc;
    color: #055160;
}

.ejercicio-descripcion {
    color: #6c757d;
    margin: 0.5rem 0;
    line-height: 1.5;
    font-size: 0.9rem;
}

.ejercicio-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.75rem 0;
    font-size: 0.85rem;
    color: #6c757d;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ejercicio-status {
    background-color: #d1e7dd;
    color: #0f5132;
    padding: 0.4rem 0.6rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ejercicio-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ejercicio-actions {
    display: flex;
    gap: 0.5rem;
}

.ejercicio-dates {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Filtros */
.filter-form {
    padding: 1.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination-link {
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    color: #0d6efd;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-link:hover {
    background-color: #e9ecef;
}

.pagination-link.active {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

/* No results */
.no-results {
    text-align: center;
    color: #6c757d;
    margin: 3rem 0;
}

/* Detalles de ejercicio */
.main-column {
    min-width: 0;
}

.sidebar-column {
    min-width: 0;
}

.ejercicio-header-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.favorito-action {
    display: flex;
}

.btn-favorito {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s ease;
    padding: 0.5rem;
}

.btn-favorito:hover {
    color: #ffc107;
}

.btn-favorito.active {
    color: #ffc107;
}

.ejercicio-descripcion-full {
    margin-bottom: 1.5rem;
}

.ejercicio-enunciado {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
}

.enunciado-content {
    line-height: 1.8;
    white-space: pre-wrap;
}

.carta-container {
    margin-top: 1rem;
}

.carta-viewer {
    width: 100%;
    min-height: 500px;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.carta-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.json-viewer {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

.autor-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
}

.stat-item strong {
    font-size: 1.5rem;
    color: #0d6efd;
}

.stat-item small {
    color: #6c757d;
}

.details-list {
    display: grid;
    gap: 0.75rem;
}

.details-list dt {
    font-weight: 600;
    color: #495057;
}

.details-list dd {
    margin: 0;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.intentos-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.intento-item {
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

/* Formulario de crear/editar ejercicio */
.ejercicio-form .card {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
}

.code-editor {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.help-text {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
    display: block;
}

.alert-error {
    background-color: #f8d7da;
    border: 1px solid #f5c2c7;
    color: #842029;
}

.alert-info {
    background-color: #cff4fc;
    border: 1px solid #b6effb;
    color: #055160;
}

@media (max-width: 768px) {
    .col-4, .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }

    .display-3 {
        font-size: 2rem;
    }

    .display-4 {
        font-size: 1.75rem;
    }

    .grid-2,
    .grid-3,
    .grid-sidebar {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .ejercicio-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .carta-actions {
        flex-direction: column;
        width: 100%;
    }

    .carta-actions .btn {
        width: 100%;
    }
}
