/* ============================================================
   FCIAA Forms & Policies Library — Frontend Styles
   ============================================================ */

/* ── Container ──────────────────────────────────────────────────────────────── */
.fciaa-lib {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0;
    color: #1a1a2e;
}

/* ── Controls bar ───────────────────────────────────────────────────────────── */
.fciaa-lib-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

/* Search */
.fciaa-search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
}
.fciaa-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #999;
    pointer-events: none;
}
.fciaa-search-input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 2px solid #dde0e8;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box;
    background: #fff;
}
.fciaa-search-input:focus { border-color: #003087; box-shadow: 0 0 0 3px rgba(0,48,135,.12); }

/* Filter tabs */
.fciaa-filter-tabs {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.fciaa-tab {
    padding: 9px 20px;
    border: 2px solid #dde0e8;
    border-radius: 8px;
    background: #fff;
    color: #555;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    letter-spacing: .02em;
}
.fciaa-tab:hover { border-color: #003087; color: #003087; }
.fciaa-tab-active { background: #003087; border-color: #003087; color: #fff !important; }

/* Result count */
.fciaa-result-count {
    font-size: 13px;
    color: #777;
    margin: 0 0 14px;
}

/* ── Document grid ───────────────────────────────────────────────────────────── */
.fciaa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

/* ── Document card ───────────────────────────────────────────────────────────── */
.fciaa-card {
    background: #fff;
    border: 1px solid #e4e7ee;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    transition: box-shadow .2s, transform .2s;
}
.fciaa-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.12); transform: translateY(-2px); }

.fciaa-card-form      { border-top: 3px solid #0d47a1; }
.fciaa-card-policy    { border-top: 3px solid #2e7d32; }
.fciaa-card-reference { border-top: 3px solid #e65100; }
.fciaa-card-charter   { border-top: 3px solid #6a1b9a; }

/* Card icon area */
.fciaa-card-icon {
    position: relative;
    padding: 18px 20px 4px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}
.fciaa-card-icon > svg {
    width: 38px;
    height: 46px;
}
.fciaa-card-form      .fciaa-card-icon > svg { color: #0d47a1; }
.fciaa-card-policy    .fciaa-card-icon > svg { color: #2e7d32; }
.fciaa-card-reference .fciaa-card-icon > svg { color: #e65100; }
.fciaa-card-charter   .fciaa-card-icon > svg { color: #6a1b9a; }

.fciaa-card-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: .06em;
    text-transform: uppercase;
    align-self: flex-start;
}
.fciaa-card-badge-form      { background: #e3f2fd; color: #0d47a1; }
.fciaa-card-badge-policy    { background: #e8f5e9; color: #1b5e20; }
.fciaa-card-badge-reference { background: #fff3e0; color: #e65100; }
.fciaa-card-badge-charter   { background: #f3e5f5; color: #6a1b9a; }

/* Card body */
.fciaa-card-body {
    padding: 8px 20px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.fciaa-card-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 6px;
    line-height: 1.35;
    color: #1a1a2e;
}
.fciaa-card-desc {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin: 0 0 10px;
    flex: 1;
}
.fciaa-card-meta {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: #999;
    align-items: center;
    margin-top: auto;
}
.fciaa-card-meta-size,
.fciaa-card-meta-date {
    display: flex;
    align-items: center;
    gap: 4px;
}
.fciaa-card-meta svg { width: 13px; height: 13px; flex-shrink: 0; }
.fciaa-card-meta-orig { cursor: default; }

/* Revision row on card */
.fciaa-card-revision {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #e65100;
    background: #fff8f4;
    border: 1px solid #ffe0cc;
    border-radius: 5px;
    padding: 4px 8px;
    margin-top: 8px;
}
.fciaa-card-revision svg { width: 12px; height: 12px; flex-shrink: 0; color: #e65100; }

/* Card action buttons */
.fciaa-card-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid #f0f1f5;
    background: #fafbfc;
}
.fciaa-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 7px;
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none !important;
    transition: all .15s;
    line-height: 1;
}
.fciaa-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.fciaa-btn-preview {
    background: #003087;
    color: #fff !important;
    border-color: #003087;
    flex: 1;
    justify-content: center;
}
.fciaa-btn-preview:hover { background: #001f5e; border-color: #001f5e; }

.fciaa-btn-download {
    background: #fff;
    color: #003087 !important;
    border-color: #003087;
    flex: 1;
    justify-content: center;
}
.fciaa-btn-download:hover { background: #003087; color: #fff !important; }

/* ── Empty states ────────────────────────────────────────────────────────────── */
.fciaa-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 20px;
    color: #999;
}
.fciaa-empty svg {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    display: block;
    color: #ccc;
    stroke-width: 1.5;
}
.fciaa-empty p { font-size: 15px; margin: 0; }

/* ── PDF Preview Modal ───────────────────────────────────────────────────────── */
.fciaa-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.fciaa-modal[hidden] { display: none; }

.fciaa-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10,10,30,.6);
    backdrop-filter: blur(3px);
}

.fciaa-modal-panel {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(0,0,0,.35);
    width: 100%;
    max-width: 900px;
    height: 90vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Modal header */
.fciaa-modal-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #003087;
    color: #fff;
    flex-shrink: 0;
}
.fciaa-modal-hdr-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.fciaa-pdf-icon { width: 22px; height: 22px; flex-shrink: 0; opacity: .8; }
.fciaa-modal-title {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fciaa-modal-hdr-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: 12px;
}

/* Modal download button */
.fciaa-modal-dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 7px;
    background: rgba(255,255,255,.15);
    border: 1.5px solid rgba(255,255,255,.4);
    color: #fff !important;
    text-decoration: none !important;
    transition: background .15s;
}
.fciaa-modal-dl-btn svg { width: 15px; height: 15px; }
.fciaa-modal-dl-btn:hover { background: rgba(255,255,255,.28); }

/* Modal close button */
.fciaa-modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: rgba(255,255,255,.8);
    display: flex;
    align-items: center;
    transition: color .15s;
}
.fciaa-modal-close-btn svg { width: 22px; height: 22px; }
.fciaa-modal-close-btn:hover { color: #fff; }

/* Modal body */
.fciaa-modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}
.fciaa-modal-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #666;
    font-size: 14px;
    background: #fff;
    z-index: 2;
}
.fciaa-spinner {
    width: 40px;
    height: 40px;
    animation: fciaa-spin 1s linear infinite;
    color: #003087;
}
@keyframes fciaa-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.fciaa-pdf-frame {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
    position: relative;
    z-index: 1;
}

/* Body lock when modal is open */
body.fciaa-modal-open { overflow: hidden; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .fciaa-grid { grid-template-columns: 1fr; }
    .fciaa-lib-controls { flex-direction: column; align-items: stretch; }
    .fciaa-filter-tabs { justify-content: center; }
    .fciaa-modal-panel { height: 95vh; max-height: none; border-radius: 10px; }
    .fciaa-modal-title { font-size: 13px; }
}
