@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #f0f7fc; /* Celeste Pastel Claro */
    --bg-secondary: #fdfbf7; /* Crema Claro */
    --bg-glass: rgba(255, 255, 255, 0.92);
    --border-glass: rgba(79, 70, 229, 0.08);
    --border-glass-focus: rgba(79, 70, 229, 0.35);
    
    --text-primary: #0f172a; /* Slate-900 */
    --text-secondary: #475569; /* Slate-600 */
    --text-muted: #94a3b8; /* Slate-400 */
    
    --accent-primary: #4f46e5; /* Indigo-600 */
    --accent-primary-hover: #4338ca; /* Indigo-700 */
    --accent-secondary: #d97706; /* Amber */
    --accent-gold: #ca8a04; /* Gold (visible sobre fondo claro) */
    --accent-rose: #e11d48; /* Rose-600 */
    --accent-emerald: #059669; /* Emerald-600 */
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 0 25px rgba(79, 70, 229, 0.15);
    --shadow-gold-glow: 0 0 25px rgba(202, 138, 4, 0.15);
    
    --font-sans: 'Poppins', sans-serif;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-primary);
    background-image: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

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

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

/* Header & Navbar */
header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 12px;
}

.logo-img {
    height: 40px;
    width: 40px;
    object-fit: contain;
    border-radius: 8px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav {
    display: flex;
    gap: 15px;
}

nav a, .nav-btn {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: var(--transition-fast);
}

nav a:hover, nav a.active {
    color: var(--accent-primary);
    background: rgba(79, 70, 229, 0.05);
}

/* Estilo Tarjeta Glassmorphic */
.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    transition: var(--transition-normal);
}

.card-glass:hover {
    border-color: rgba(79, 70, 229, 0.15);
}

/* Títulos y textos */
h1, h2, h3, h4 {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.section-title {
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
    font-weight: 700;
}

.section-subtitle {
    font-size: 15px;
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    font-family: var(--font-sans);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-hover) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3), var(--shadow-glow);
}

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

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: rgba(15, 23, 42, 0.15);
}

.btn-danger {
    background: var(--accent-rose);
    color: white;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.15);
}

.btn-danger:hover {
    background: #d90429;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.25);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: 12px;
}

.btn-full {
    width: 100%;
}

/* Inputs y Formulario */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

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

.form-control {
    width: 100%;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

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

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 15px;
    cursor: pointer;
    user-select: none;
}

.form-check input {
    margin-top: 4px;
    cursor: pointer;
}

.form-check-label {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(5, 150, 105, 0.1);
    color: var(--accent-emerald);
}

.badge-danger {
    background: rgba(225, 29, 72, 0.1);
    color: var(--accent-rose);
}

.badge-warning {
    background: rgba(217, 119, 6, 0.1);
    color: var(--accent-secondary);
}

/* Tarjetas de Obras / Grupos */
.group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.sculpture-card {
    background: #ffffff;
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    overflow: hidden;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sculpture-card:hover {
    transform: translateY(-4px);
    border-color: rgba(79, 70, 229, 0.15);
    box-shadow: var(--shadow-md);
}

.sculpture-img-wrapper {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 Aspect Ratio */
    background: #f1f5f9;
    overflow: hidden;
}

.sculpture-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-normal);
}

.sculpture-card:hover .sculpture-img {
    transform: scale(1.05);
}

.sculpture-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.sculpture-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.sculpture-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.sculpture-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    flex-grow: 1;
}

/* Galería de miniaturas */
.thumbnail-gallery {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.thumbnail-gallery::-webkit-scrollbar {
    height: 4px;
}

.thumbnail-gallery::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.6;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.thumbnail:hover, .thumbnail.active {
    opacity: 1;
    border-color: var(--accent-primary);
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    max-width: 90%;
    max-height: 80%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,0.3);
    object-fit: contain;
    transform: scale(0.95);
    transition: transform var(--transition-normal);
}

.lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 32px;
    cursor: pointer;
    background: none;
    border: none;
}

.lightbox-prev, .lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.lightbox-prev:hover, .lightbox-next:hover {
    background: rgba(255,255,255,0.25);
}

.lightbox-prev { left: -70px; }
.lightbox-next { right: -70px; }

@media(max-width: 768px) {
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
}

/* Sistema de Estrellas de Votación */
.rating-group {
    background: #ffffff;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-sm);
}

.rating-title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rating-criterio-name {
    font-size: 14px;
    font-weight: 600;
}

.rating-criterio-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

.stars {
    display: inline-flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.stars input {
    display: none;
}

.stars label {
    font-size: 26px;
    color: #cbd5e1; /* Slate-300 */
    cursor: pointer;
    padding: 0 4px;
    transition: transform 0.1s ease, color 0.1s ease;
}

.stars label:hover,
.stars label:hover ~ label,
.stars input:checked ~ label {
    color: #eab308; /* Amber-500 */
    text-shadow: 0 0 8px rgba(234, 179, 8, 0.3);
}

.stars label:active {
    transform: scale(1.2);
}

/* Tablas Modernas */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: #ffffff;
}

th {
    background: #f1f5f9;
    padding: 14px 18px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-glass);
}

td {
    padding: 14px 18px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-glass);
    transition: var(--transition-fast);
}

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

tr:hover td {
    background: var(--bg-secondary);
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    background: #ffffff;
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.pagination a:hover {
    background: var(--bg-secondary);
}

.pagination span.current {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Pantalla del Ganador / Celebración */
.winner-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #ffffff 0%, #e2e8f0 100%);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.winner-screen.active {
    opacity: 1;
    visibility: visible;
}

.winner-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1501;
}

.winner-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 2px solid var(--accent-gold);
    border-radius: 24px;
    max-width: 550px;
    width: 100%;
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-gold-glow);
    z-index: 1502;
    transform: scale(0.8) translateY(30px);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.winner-screen.active .winner-card {
    transform: scale(1) translateY(0);
}

.winner-crown {
    font-size: 64px;
    margin-bottom: 10px;
    animation: float 3s ease-in-out infinite;
    display: inline-block;
}

.winner-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent-gold);
    text-transform: uppercase;
    margin-bottom: 20px;
    text-shadow: 0 0 15px rgba(202, 138, 4, 0.15);
}

.winner-image-container {
    width: 100%;
    height: 250px;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid rgba(15, 23, 42, 0.1);
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.winner-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.winner-group-name {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.winner-score {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.winner-score span {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

/* Animaciones */
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0); }
    50% { transform: translateY(-10px) rotate(3deg); }
}

/* Dashboard administrativo */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    font-size: 32px;
    width: 50px;
    height: 50px;
    background: rgba(79, 70, 229, 0.05);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Gráficos sencillos por CSS */
.bar-chart-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.bar-chart-row {
    display: flex;
    flex-direction: column;
}

.bar-chart-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.bar-chart-track {
    width: 100%;
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.bar-chart-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary) 0%, #818cf8 100%);
    border-radius: 6px;
    width: 0;
    transition: width 1s ease;
}

.bar-chart-fill.first-place {
    background: linear-gradient(90deg, var(--accent-gold) 0%, #fef08a 100%);
}

/* QR Code Section */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.qr-box {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0,0,0,0.05);
}

/* Grid de administración de imágenes */
.admin-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
    margin-top: 15px;
}

.admin-image-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    aspect-ratio: 1;
    background: #ffffff;
}

.admin-image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-image-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    justify-content: space-around;
    padding: 4px;
}

.admin-image-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 11px;
    padding: 4px;
    text-decoration: none;
}

.admin-image-btn:hover {
    color: var(--accent-primary);
}

.admin-image-btn.btn-delete:hover {
    color: var(--accent-rose);
}

.admin-image-card.is-main {
    border: 2px solid var(--accent-gold);
    box-shadow: var(--shadow-gold-glow);
}

.admin-main-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--accent-gold);
    color: white;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Buscador y Filtros */
.filters-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: #ffffff;
}

.filters-row .form-control {
    flex: 1;
    min-width: 200px;
}

.filters-row select.form-control {
    width: auto;
    flex: 0 0 auto;
}

@media(max-width: 768px) {
    .filters-row {
        flex-direction: column;
    }
    .filters-row select.form-control {
        width: 100%;
    }
}

/* Alertas */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(5, 150, 105, 0.1);
    border-color: rgba(5, 150, 105, 0.15);
    color: #047857;
}

.alert-danger {
    background: rgba(225, 29, 72, 0.1);
    border-color: rgba(225, 29, 72, 0.15);
    color: #b91c1c;
}

.alert-info {
    background: rgba(79, 70, 229, 0.1);
    border-color: rgba(79, 70, 229, 0.15);
    color: #4338ca;
}

/* Efecto de cargando (Spinner) */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

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

/* Estilo para los líderes de los grupos */
.ranking-row-1 {
    background: rgba(202, 138, 4, 0.04) !important;
}
.ranking-row-1 td {
    color: var(--accent-gold);
    font-weight: 600;
}
.ranking-trophy {
    font-size: 16px;
    margin-right: 5px;
}

/* --- Ajustes de Responsividad Móvil --- */
@media(max-width: 600px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    nav {
        width: 100%;
        justify-content: center;
        gap: 5px;
        flex-wrap: wrap;
    }
    nav a, .nav-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    .container {
        padding: 10px;
    }
    .hero-section {
        padding: 30px 15px;
        margin-bottom: 20px;
    }
    .hero-title {
        font-size: 26px;
    }
    .hero-desc {
        font-size: 14px;
        margin-bottom: 20px;
    }
    .card-glass {
        padding: 16px;
        border-radius: 12px;
        margin-bottom: 16px;
    }
    .votation-header {
        padding: 20px 10px;
    }
}

@media(max-width: 480px) {
    .winner-card {
        padding: 24px 16px;
        border-radius: 16px;
    }
    .winner-title {
        font-size: 24px;
    }
    .winner-image-container {
        height: 180px;
    }
    .winner-group-name {
        font-size: 20px;
    }
    .stars label {
        font-size: 22px;
        padding: 0 2px;
    }
    .rating-group {
        padding: 10px 12px;
    }
    .rating-title-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    th, td {
        padding: 10px 12px;
        font-size: 12px;
    }
}
