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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Navbar */
.navbar {
    background: var(--primary);
    color: #fff;
    padding: 12px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.nav-links span {
    opacity: 0.9;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.btn-sm:hover {
    background: rgba(255,255,255,0.3);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-full {
    width: 100%;
}

.btn-month {
    background: #fff;
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    position: relative;
    flex: 1;
    min-width: 0;
}

.btn-month:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-month.btn-active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.btn-month.btn-current {
    border-color: var(--primary);
}

.badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 6px;
    vertical-align: middle;
}

.btn-active .badge {
    background: rgba(255,255,255,0.3);
}

/* Month filter */
.month-filter {
    display: flex;
    gap: 12px;
    margin: 24px 0;
}

/* Event grid */
.eventos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.evento-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}



.evento-img {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.evento-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.evento-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.evento-titulo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
    line-height: 1.3;
}

.evento-meta {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.evento-ubicacion {
    font-size: 0.95rem;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.evento-detalle {
    font-size: 0.9rem;
    color: var(--gray-600);
    line-height: 1.6;
    flex: 1;
}

/* Clickable card link */
.evento-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.evento-card-link:hover .evento-card {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Detail page */
.detalle-container {
    padding-top: 20px;
    padding-bottom: 40px;
}

.btn-back {
    display: inline-block;
    margin-bottom: 20px;
    color: var(--primary);
    background: none;
    padding: 8px 0;
    font-weight: 500;
}

.btn-back:hover {
    color: var(--primary-dark);
}

.detalle-evento {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.detalle-imagen {
    width: 100%;
    max-height: 500px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
}

.detalle-imagen img {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: contain;
}

.detalle-body {
    padding: 32px;
}

.detalle-titulo {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 20px;
    line-height: 1.2;
}

.detalle-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gray-200);
}

.detalle-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
}

.meta-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-800);
}

.detalle-descripcion {
    margin-bottom: 28px;
}

.detalle-descripcion h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.detalle-descripcion p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--gray-600);
    white-space: pre-line;
}

/* Map embed */
.detalle-mapa {
    margin-top: 28px;
}

.detalle-mapa h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.map-embed-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    overflow: hidden;
    border-radius: var(--radius-sm);
}

.map-embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
    font-size: 1.1rem;
}

/* Forms */
.form-evento {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 32px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
    color: var(--gray-800);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input[type="file"] {
    width: 100%;
    padding: 8px 0;
    font-size: 0.9rem;
}

.help-text {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: 4px;
}

/* Toggle switch */
.form-check {
    display: flex;
    align-items: center;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--gray-700);
    user-select: none;
}

.toggle-switch-wrapper {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.toggle-switch-wrapper input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--gray-300);
    border-radius: 12px;
    transition: background 0.2s;
    display: block;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch-wrapper input:checked + .toggle-switch {
    background: var(--success);
}

.toggle-switch-wrapper input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

.toggle-text {
    line-height: 1.4;
}

/* Status badges */
.badge-estado {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-estado.activo {
    background: #dcfce7;
    color: #166534;
}

.badge-estado.inactivo {
    background: #fee2e2;
    color: #991b1b;
}

.tr-inactive {
    opacity: 0.6;
}

.btn-edit {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-edit:hover {
    background: var(--gray-300);
}

/* Image preview in edit form */
.imagen-actual {
    margin-bottom: 8px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--danger);
    cursor: pointer;
}

/* Alert */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Table */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 32px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.9rem;
}

.table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

.table td {
    border-top: 1px solid var(--gray-200);
}

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-100);
}

.login-container {
    background: #fff;
    padding: 40px 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    margin: 16px;
}

.login-container h1 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 24px;
    color: var(--gray-900);
}

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

.login-link {
    text-align: center;
    margin-top: 16px;
}

.login-link a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.login-link a:hover {
    text-decoration: underline;
}

/* Footer */
.footer {
    background: #fff;
    border-top: 1px solid var(--gray-200);
    padding: 20px 0;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.85rem;
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    html { font-size: 15px; }

    .month-filter {
        flex-direction: column;
        gap: 8px;
    }

    .btn-month {
        padding: 12px 20px;
    }

    .eventos-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

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

    .form-evento {
        padding: 16px;
    }

    .login-container {
        margin: 12px;
        padding: 28px 20px;
    }

    .evento-img {
        height: 180px;
    }

    .nav-links {
        gap: 8px;
        font-size: 0.8rem;
    }

    .nav-links span {
        display: none;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .eventos-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .month-filter {
        gap: 10px;
    }

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

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

    .evento-titulo {
        font-size: 1.1rem;
    }

    .evento-meta {
        flex-direction: column;
        gap: 4px;
    }

    .table th, .table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}
