/* ==========================================
   ASOCIACIÓNS DE GALICIA v3 — Modern Light
   ========================================== */

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

:root {
    --color-bg: #fafbfc;
    --color-surface: #ffffff;
    --color-primary: #1e3a5f;
    --color-primary-light: #2563eb;
    --color-accent: #2563eb;
    --color-accent-soft: #eff6ff;
    --color-accent-mid: #dbeafe;
    --color-gold: #ca8a04;
    --color-gold-soft: #fefce8;
    --color-gold-border: #fde68a;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-text-light: #9ca3af;
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---- HEADER ---- */
.site-header {
    background: var(--color-surface);
    color: var(--color-text);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--color-border);
    transition: all 0.3s ease;
}

.header-top {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px 12px;
    transition: padding 0.3s ease;
}

.header-top h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--color-primary);
    letter-spacing: -0.02em;
    margin-bottom: 2px;
    transition: font-size 0.3s ease;
}

.header-top h1 img {
    height: 50px;
    display: block;
}

.header-subtitle {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    font-weight: 400;
    transition: all 0.3s ease;
}

.header-subtitle strong { color: var(--color-text); font-weight: 600; }

/* ---- HEADER COMPACT ---- */
.site-header.compact .header-top {
    padding: 8px 24px 4px;
}

.site-header.compact .header-top h1 { font-size: 1.1rem; }
.site-header.compact .header-top h1 img { height: 32px; }

.site-header.compact .header-subtitle {
    font-size: 0; opacity: 0; height: 0; margin: 0; overflow: hidden;
}

.site-header.compact .search-inner { padding: 6px 24px 8px; }

.site-header.compact .filters-row {
    max-height: 0; opacity: 0; overflow: hidden; margin: 0; padding: 0;
    transition: all 0.3s ease;
}

.site-header.compact .filters-toggle-row { display: flex; }

.site-header.compact.filters-open .filters-row {
    max-height: 200px; opacity: 1; margin-top: 8px;
}

.filters-toggle-row {
    display: none;
    justify-content: center;
    padding-top: 4px;
}

.btn-toggle-filters {
    background: var(--color-accent-soft);
    border: 1px solid var(--color-accent-mid);
    color: var(--color-accent);
    font-size: 0.78rem;
    font-family: inherit;
    padding: 4px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.btn-toggle-filters:hover { background: var(--color-accent-mid); }

/* ---- SEARCH ---- */
.search-section {
    background: var(--color-bg);
    border-top: 1px solid var(--color-border-light);
}

.search-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    transition: padding 0.3s ease;
}

.search-box {
    position: relative;
    margin-bottom: 12px;
}

.search-box svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-light);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 13px 16px 13px 48px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.search-box input::placeholder { color: var(--color-text-light); }
.search-box input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ---- FILTERS ---- */
.filters-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    transition: all 0.3s ease;
}

.filter-select {
    flex: 1;
    min-width: 160px;
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    box-shadow: var(--shadow-sm);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-clear {
    padding: 10px 18px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-weight: 500;
}

.btn-clear:hover { background: var(--color-border-light); color: var(--color-text); }

/* ---- RESULTS BAR ---- */
.results-bar {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px 8px;
}

.results-count { font-size: 0.85rem; color: var(--color-text-muted); }
.results-count strong { color: var(--color-accent); font-weight: 700; }

/* ---- GRID ---- */
.results-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 24px 40px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

/* ---- CARD ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
}

.card:hover {
    border-color: var(--color-accent-mid);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.card-top {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.card-cat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--color-accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-accent);
}

.card-cat-icon svg { width: 18px; height: 18px; }

.card-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.4;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tipo {
    font-size: 0.75rem;
    color: var(--color-text-light);
    font-weight: 400;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border-light);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.badge-provincia { background: #eff6ff; color: #1d4ed8; }
.badge-municipio { background: #ecfdf5; color: #059669; }
.badge-ambito { background: #f5f3ff; color: #7c3aed; }
.badge-premium { background: var(--color-gold-soft); color: #92400e; font-weight: 600; }

/* Premium card */
.card.card--premium {
    border: 1px solid var(--color-gold-border);
    background: linear-gradient(135deg, var(--color-gold-soft) 0%, var(--color-surface) 50%);
}

.card.card--premium:hover {
    box-shadow: 0 4px 16px rgba(202, 138, 4, 0.12);
}

.card--premium .card-cat-icon {
    background: var(--color-gold-soft);
    color: var(--color-gold);
}

/* ---- PAGINATION ---- */
.pagination {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.pagination button {
    padding: 10px 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

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

.pagination button:disabled { opacity: 0.35; cursor: default; }
.pagination .page-info { font-size: 0.85rem; color: var(--color-text-muted); padding: 0 12px; }

/* ---- DETAIL PAGE ---- */
.site-header--compact { border-bottom: 1px solid var(--color-border); }
.site-header--compact .header-top {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.site-header--compact .header-top h1 { font-size: 1rem; margin: 0; }

.header-back {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color var(--transition);
}

.header-back:hover { color: var(--color-primary); }
.header-title-sm { font-family: 'Playfair Display', Georgia, serif; color: var(--color-primary); }

.detail-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.detail-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.detail-card-header {
    padding: 24px 28px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.detail-cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.detail-cat-badge svg { width: 14px; height: 14px; flex-shrink: 0; }

.premium-badge {
    background: var(--color-gold-soft);
    color: #92400e;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
}

.detail-card-title {
    padding: 18px 28px 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-primary);
}

.detail-descripcion {
    padding: 18px 28px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.75;
    border-bottom: 1px solid var(--color-border-light);
}

.detail-fields {
    padding: 24px 28px 28px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-field { }

.detail-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-light);
    margin-bottom: 3px;
}

.detail-value {
    font-size: 0.9rem;
    color: var(--color-text);
    font-weight: 500;
}

.detail-value a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}

.detail-value a:hover { text-decoration: underline; }

/* CTA Premium */
.cta-premium {
    margin-top: 28px;
    background: var(--color-gold-soft);
    border: 1px solid var(--color-gold-border);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
}

.cta-premium h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    color: #78350f;
    margin-bottom: 8px;
}

.cta-premium p { font-size: 0.85rem; color: #a16207; margin-bottom: 18px; line-height: 1.6; }

.btn-premium {
    display: inline-block;
    background: var(--color-gold);
    color: white;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(202, 138, 4, 0.25);
}

.btn-premium:hover { background: #a16207; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(202, 138, 4, 0.3); }

/* ---- LOADING / EMPTY ---- */
.loading { text-align: center; padding: 80px 20px; color: var(--color-text-muted); }

.spinner {
    width: 28px; height: 28px;
    border: 2.5px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 14px;
}

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

.no-results { text-align: center; padding: 80px 20px; }
.no-results-icon { font-size: 2.5rem; margin-bottom: 14px; }
.no-results h3 { font-size: 1rem; margin-bottom: 6px; color: var(--color-text); }
.no-results p { font-size: 0.85rem; color: var(--color-text-muted); }

/* ---- FOOTER ---- */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-light);
    text-align: center;
    padding: 24px;
    font-size: 0.78rem;
}

/* ---- ADMIN ---- */
.admin-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
}

.admin-login {
    max-width: 360px;
    margin: 80px auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 36px;
    box-shadow: var(--shadow-md);
}

.admin-login h2 { font-size: 1.2rem; margin-bottom: 24px; text-align: center; font-weight: 600; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--color-text-muted); margin-bottom: 5px; }

.form-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition);
    background: var(--color-surface);
}

.form-input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.form-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    font-family: inherit;
    min-height: 100px;
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary { background: var(--color-accent); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: var(--color-border-light); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border); }
.btn-full { width: 100%; justify-content: center; }

.admin-search { margin-bottom: 24px; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--color-bg);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--color-border);
}

.admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border-light);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-table tr:hover td { background: var(--color-accent-soft); }

.btn-edit {
    padding: 6px 14px;
    font-size: 0.78rem;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    border: 1px solid var(--color-accent-mid);
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: var(--transition);
}

.btn-edit:hover { background: var(--color-accent-mid); }

.edit-form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.edit-form h3 { font-size: 1rem; margin-bottom: 18px; font-weight: 600; }

.edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.edit-grid .form-group.full { grid-column: 1 / -1; }

.alert {
    padding: 12px 18px;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    margin-bottom: 16px;
    font-weight: 500;
}

.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.admin-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--color-border);
}

.admin-bar h2 { font-size: 1.2rem; font-weight: 600; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .header-top h1 { font-size: 1.3rem; }
    .header-top h1 img { height: 40px; }
    .site-header.compact .header-top h1 { font-size: 1rem; }
    .site-header.compact .header-top h1 img { height: 28px; }
    .results-grid { grid-template-columns: 1fr; padding: 8px 16px 32px; }
    .search-inner { padding: 12px 16px; }
    .header-top { padding: 14px 16px 10px; }
    .results-bar { padding: 14px 16px 6px; }
    .filters-row { flex-direction: column; }
    .filter-select { width: 100%; }
    .pagination { padding: 0 16px 32px; }
    .detail-page { padding: 24px 16px 48px; }
    .detail-card-title { font-size: 1.3rem; padding: 14px 20px 0; }
    .detail-card-header { padding: 20px 20px 0; }
    .detail-fields { grid-template-columns: 1fr; padding: 20px; gap: 16px; }
    .detail-descripcion { padding: 14px 20px; }
    .edit-grid { grid-template-columns: 1fr; }
}

