/* ============================================================
   AIFAESA Lejislasaun – app.css
   Design: Refined Legal / Institutional
   Palette: Deep Navy · Warm Gold · Ivory · Slate
   Fonts: Playfair Display (headings) + Source Sans 3 (body)
   ============================================================ */

:root {
    --navy:      #0d1b2a;
    --navy-mid:  #1b3a5c;
    --navy-light:#2e5f8a;
    --gold:      #c8a84b;
    --gold-light:#e2c675;
    --gold-pale: #fdf5dc;
    --ivory:     #fafaf7;
    --ivory-dark:#f0ede4;
    --slate:     #64748b;
    --slate-light:#94a3b8;
    --text:      #1e293b;
    --text-muted:#64748b;
    --border:    #ddd8cc;
    --white:     #ffffff;
    --danger:    #c0392b;
    --success:   #27ae60;

    --radius:    6px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(13,27,42,0.08);
    --shadow:    0 4px 16px rgba(13,27,42,0.12);
    --shadow-lg: 0 12px 40px rgba(13,27,42,0.18);
    --transition: 0.2s ease;

    --header-h: 68px;
}

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--ivory);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--navy-mid); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold); }

img { max-width: 100%; }

/* ── Header ───────────────────────────────────────────── */
.site-header {
    background: var(--navy);
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    border-bottom: 2px solid var(--gold);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 32px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--white) !important;
}

.brand-logo {
    width: 44px;
    height: 44px;
    background: var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-symbol {
    font-size: 22px;
    line-height: 1;
    color: var(--navy);
}
.logo-symbol.small { font-size: 16px; }

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0.02em;
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--gold-light);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.header-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.8) !important;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
}
.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: var(--white) !important;
}
.btn-add {
    background: var(--gold) !important;
    color: var(--navy) !important;
    font-weight: 700;
}
.btn-add:hover {
    background: var(--gold-light) !important;
    color: var(--navy) !important;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: auto;
}
.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
    transition: all var(--transition);
}

.mobile-nav {
    display: none;
    flex-direction: column;
    background: var(--navy-mid);
    padding: 8px 16px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.mobile-nav.open { display: flex; }
.mobile-nav-link {
    padding: 10px 8px;
    color: rgba(255,255,255,0.85) !important;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* ── Main & Layout ───────────────────────────────────── */
.site-main {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 24px;
}

/* ── Page Hero ───────────────────────────────────────── */
.page-hero {
    margin-bottom: 36px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.page-hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--navy);
    line-height: 1.2;
    margin-bottom: 8px;
}
.page-hero .subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}
.hero-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--gold-pale);
    border: 1px solid var(--gold);
    color: var(--navy-mid);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    margin-top: 10px;
}

/* ── Search & Filter Bar ─────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
}
.search-wrap .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slate-light);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 11px 14px 11px 42px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.search-input:focus {
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(46,95,138,0.12);
}

.filter-select {
    padding: 11px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--white);
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--navy-light); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 20px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn-primary {
    background: var(--navy-mid);
    color: var(--white);
}
.btn-primary:hover {
    background: var(--navy);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.btn-gold {
    background: var(--gold);
    color: var(--navy);
}
.btn-gold:hover {
    background: var(--gold-light);
    color: var(--navy);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}
.btn-outline:hover {
    border-color: var(--navy-light);
    color: var(--navy-mid);
}
.btn-danger {
    background: var(--danger);
    color: var(--white);
}
.btn-danger:hover {
    background: #a93226;
    color: var(--white);
}
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ── Acts Table ──────────────────────────────────────── */
.acts-table-wrap {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

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

.acts-table thead {
    background: var(--navy);
    color: var(--white);
}
.acts-table thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}
.acts-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}
.acts-table thead th.sortable:hover { color: var(--gold-light); }
.acts-table thead th i { margin-left: 4px; font-size: 0.7rem; }

.acts-table tbody tr {
    border-bottom: 1px solid var(--ivory-dark);
    transition: background var(--transition);
}
.acts-table tbody tr:last-child { border-bottom: none; }
.acts-table tbody tr:hover { background: var(--gold-pale); }
.acts-table tbody tr.hidden-row { display: none; }

.acts-table td {
    padding: 14px 16px;
    vertical-align: middle;
    font-size: 0.92rem;
}

.act-number-badge {
    display: inline-flex;
    align-items: center;
    background: var(--navy);
    color: var(--white);
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

.type-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--ivory-dark);
    color: var(--navy-mid);
    border: 1px solid var(--border);
}

.act-title-link {
    font-weight: 600;
    color: var(--navy-mid);
    display: block;
    margin-bottom: 2px;
}
.act-title-link:hover { color: var(--gold); }

.act-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-family: 'Playfair Display', serif; font-size: 1.4rem; color: var(--slate); margin-bottom: 8px; }

/* ── Pagination ──────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--ivory);
}
.pagination-info { font-size: 0.85rem; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 6px; }
.page-btn {
    width: 34px;
    height: 34px;
    border: 2px solid var(--border);
    background: var(--white);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text);
}
.page-btn:hover, .page-btn.active {
    background: var(--navy);
    border-color: var(--navy);
    color: var(--white);
}
.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13,27,42,0.65);
    backdrop-filter: blur(3px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}
.modal-overlay.open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--navy);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    color: var(--white);
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius);
    transition: color var(--transition);
}
.modal-close:hover { color: var(--white); }

.modal-body { padding: 24px; }

/* ── Form ─────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--navy-mid);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.form-label .req { color: var(--gold); margin-left: 2px; }

.form-control {
    padding: 10px 13px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--white);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}
.form-control:focus {
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(46,95,138,0.12);
}

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

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Act View Page ───────────────────────────────────── */
.act-view-header {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-sm);
}

.act-view-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.act-view-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.9rem;
    font-weight: 900;
    color: var(--navy);
    line-height: 1.3;
    margin-bottom: 10px;
}

.act-view-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 18px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.meta-item {
    background: var(--ivory-dark);
    border-radius: var(--radius);
    padding: 10px 14px;
}
.meta-item .meta-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    color: var(--slate);
    margin-bottom: 3px;
}
.meta-item .meta-val {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--navy-mid);
}

.act-view-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.act-content-frame {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.frame-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--ivory-dark);
    border-bottom: 1px solid var(--border);
}
.frame-toolbar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--slate);
    display: flex;
    align-items: center;
    gap: 7px;
}

.act-iframe {
    width: 100%;
    height: 80vh;
    border: none;
    display: block;
}

/* ── Alerts ──────────────────────────────────────────── */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: #eafaf1; border-left: 4px solid var(--success); color: #1a6b3c; }
.alert-error   { background: #fdf0ee; border-left: 4px solid var(--danger);  color: #7b2d26; }

/* ── Breadcrumb ──────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.83rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--navy-light); }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb .sep { color: var(--slate-light); }

/* ── Footer ──────────────────────────────────────────── */
.site-footer {
    background: var(--navy);
    color: rgba(255,255,255,0.5);
    padding: 20px 24px;
    margin-top: auto;
    border-top: 2px solid var(--gold);
}
.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.8rem;
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gold-light);
    font-weight: 600;
    margin-right: auto;
}
.footer-sep { opacity: 0.3; }
.footer-links a { color: rgba(255,255,255,0.5); }
.footer-links a:hover { color: var(--gold-light); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    .site-header { height: auto; }
    .header-inner { height: var(--header-h); }
    .header-nav { display: none; }
    .mobile-menu-toggle { display: flex; }

    .site-main { padding: 24px 16px; }
    .page-hero h1 { font-size: 1.6rem; }

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

    .acts-table { font-size: 0.85rem; }
    .acts-table td:nth-child(4),
    .acts-table th:nth-child(4) { display: none; }

    .act-view-title { font-size: 1.4rem; }
    .act-view-header { padding: 20px; }
    .act-iframe { height: 60vh; }

    .footer-inner { flex-direction: column; text-align: center; }
    .footer-brand { margin-right: 0; }
}

/* ── Loading Spinner ──────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── No-results row ──────────────────────────────────── */
.no-results-row { display: none; }
.no-results-row.visible { display: table-row; }
