/* FO Generator - Frontend Styles
   MEDonline branding: #e4003a (primary/red), #0e233e (secondary/navy), #61647f (body text)
   Uses Automatic CSS (ACSS) variables with MEDonline fallbacks.
*/

/* ===== TOOLBAR ===== */
.fo-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-m, 1rem);
    padding: var(--space-s, 0.75rem) 0;
    flex-wrap: wrap;
}

.fo-toolbar-left {
    display: flex;
    align-items: center;
}

.fo-toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-s, 0.75rem);
    flex-wrap: wrap;
}

/* Status Toggle */
.fo-status-toggle {
    display: flex;
    background: var(--neutral-ultra-light, #f0f1f4);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--neutral-light, #c8c9d3);
    box-shadow: inset 0 1px 2px rgba(14, 35, 62, 0.06);
}

.fo-toggle-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--neutral, #61647f);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.fo-toggle-btn:hover {
    color: var(--base, #0e233e);
}

.fo-toggle-btn.is-active {
    background: var(--white, #fff);
    color: var(--base, #0e233e);
    box-shadow: 0 1px 4px rgba(14, 35, 62, 0.12), 0 0 0 1px rgba(14, 35, 62, 0.04);
}

/* Sort Control */
.fo-sort-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fo-sort-label {
    font-size: 0.8125rem;
    color: var(--neutral, #61647f);
    font-weight: 500;
    white-space: nowrap;
}

.fo-sort-select {
    padding: 6px 28px 6px 10px;
    border: 1px solid var(--neutral-light, #c8c9d3);
    border-radius: 6px;
    background: var(--white, #fff);
    color: var(--base, #0e233e);
    font-size: 0.8125rem;
    cursor: pointer;
    appearance: auto;
    transition: border-color 0.15s;
}

.fo-sort-select:hover {
    border-color: #a0a2b0;
}

.fo-sort-select:focus {
    outline: none;
    border-color: var(--primary, #e4003a);
    box-shadow: 0 0 0 2px rgba(228, 0, 58, 0.12);
}

/* Search */
.fo-search-input {
    padding: 6px 12px;
    border: 1px solid var(--neutral-light, #c8c9d3);
    border-radius: 6px;
    background: var(--white, #fff);
    color: var(--base, #0e233e);
    font-size: 0.8125rem;
    width: 200px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fo-search-input::placeholder {
    color: var(--neutral, #61647f);
    opacity: 0.5;
}

.fo-search-input:hover {
    border-color: #a0a2b0;
}

.fo-search-input:focus {
    outline: none;
    border-color: var(--primary, #e4003a);
    box-shadow: 0 0 0 2px rgba(228, 0, 58, 0.12);
}

/* ===== PROJECT GRID ===== */
.fo-project-grid {
    display: grid;
    gap: var(--grid-gap, 1.25rem);
    padding: var(--space-s, 0.75rem) 0;
}

.fo-project-grid.fo-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.fo-project-grid.fo-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.fo-project-grid.fo-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ===== PROJECT CARD ===== */
.fo-project-card {
    background: var(--white, #fff);
    border: 1px solid var(--neutral-light, #d8d9e0);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    font-size: 0.8125rem;
    box-shadow: 0 1px 3px rgba(14, 35, 62, 0.04);
}

.fo-project-card:hover {
    box-shadow: 0 8px 28px rgba(14, 35, 62, 0.12), 0 2px 8px rgba(14, 35, 62, 0.06);
    transform: translateY(-3px);
    border-color: rgba(14, 35, 62, 0.15);
}

/* Card Header — navy bar with subtle gradient */
.fo-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 14px;
    background: linear-gradient(135deg, #0e233e 0%, #162d4e 100%);
    border-bottom: none;
    position: relative;
}

.fo-card-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 14px;
    right: 14px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(228, 0, 58, 0.4), transparent);
}

.fo-card-number {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.6875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.5px;
}

.fo-card-status {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 2px 8px;
    border-radius: 20px;
}

.fo-card-status.status-active {
    background: rgba(22, 163, 74, 0.2);
    color: #15803d;
}

.fo-card-status.status-completed {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

/* Card Body */
.fo-card-body {
    padding: 12px 14px 8px;
    flex-grow: 1;
}

.fo-card-title {
    font-size: 0.9375rem;
    font-weight: var(--heading-font-weight, 900);
    color: var(--base, #0e233e);
    margin: 0 0 2px 0;
    line-height: 1.3;
}

.fo-card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
}

.fo-card-title a:hover {
    color: var(--primary, #e4003a);
}

.fo-card-subtitle {
    font-size: 0.75rem;
    color: var(--neutral, #61647f);
    margin: 0 0 6px 0;
}

.fo-card-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--secondary, #0e233e);
    background: var(--neutral-ultra-light, #f0f1f4);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--neutral-light, #d8d9e0);
}

/* Card URLs */
.fo-card-urls {
    padding: 0 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}

.fo-card-url {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.6875rem;
    overflow: hidden;
}

.fo-card-url .fo-url-icon {
    flex-shrink: 0;
    font-size: 0.625rem;
    opacity: 0.5;
}

.fo-card-url a {
    color: var(--primary, #e4003a);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s;
}

.fo-card-url a:hover {
    color: var(--secondary, #0e233e);
}

/* Card Details */
.fo-card-details {
    padding: 0 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.fo-card-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    padding: 4px 0;
    border-bottom: 1px solid #f0f1f4;
}

.fo-card-detail:last-child {
    border-bottom: none;
}

.fo-detail-label {
    color: var(--neutral, #61647f);
    font-weight: 500;
}

.fo-detail-value {
    color: var(--base, #0e233e);
    font-weight: 600;
}

/* Card Documents */
.fo-card-documents {
    padding: 0 14px 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.fo-doc-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--secondary, #0e233e) !important;
    background: var(--neutral-ultra-light, #f0f1f4);
    border: 1px solid var(--neutral-light, #d8d9e0);
    border-radius: 4px;
    text-decoration: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.fo-doc-link:hover {
    background: var(--primary, #e4003a);
    color: var(--white, #fff) !important;
    border-color: var(--primary, #e4003a);
    box-shadow: 0 2px 6px rgba(228, 0, 58, 0.25);
    transform: translateY(-1px);
}

/* Card Footer */
.fo-card-footer {
    padding: 10px 14px;
    border-top: 1px solid #f0f1f4;
    text-align: center;
    margin-top: auto;
    display: flex;
    gap: 8px;
}

.fo-card-button {
    display: inline-block;
    padding: 8px 16px;
    background: var(--secondary, #0e233e);
    color: var(--white, #fff) !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    box-sizing: border-box;
    text-align: center;
}

.fo-card-button:hover {
    background: var(--primary, #e4003a);
    color: var(--white, #fff) !important;
    box-shadow: 0 3px 10px rgba(228, 0, 58, 0.2);
}

.fo-card-button--secondary {
    background: transparent;
    color: var(--secondary, #0e233e) !important;
    border: 1.5px solid var(--neutral-light, #d8d9e0);
}

.fo-card-button--secondary:hover {
    background: var(--secondary, #0e233e);
    color: var(--white, #fff) !important;
    border-color: var(--secondary, #0e233e);
    box-shadow: 0 3px 10px rgba(14, 35, 62, 0.2);
}

/* Empty State Hints */
.fo-empty-hint {
    font-size: 0.75rem;
    color: var(--neutral, #61647f);
    font-style: italic;
    opacity: 0.7;
    padding: 4px 0;
}

.fo-single-documents .fo-empty-hint {
    padding: 0 0 4px;
}

/* No Results */
.fo-no-projects,
.fo-no-results {
    text-align: center;
    padding: 3rem 1.25rem;
    color: var(--neutral, #61647f);
    font-size: 1rem;
}

/* Archive Page */
.fo-archive-header {
    padding: 2rem 0 1.25rem;
}

.fo-archive-header h1 {
    font-size: var(--h2, 2.5rem);
    font-weight: var(--heading-font-weight, 900);
    color: var(--base, #0e233e);
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
}

.fo-archive-header p {
    font-size: 1rem;
    color: var(--neutral, #61647f);
    margin: 0;
}

.fo-archive-container {
    max-width: var(--content-width, 1200px);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ===== RESPONSIVE ===== */

/* Tablet landscape */
@media (max-width: 1200px) {
    .fo-project-grid.fo-columns-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet portrait */
@media (max-width: 1024px) {
    .fo-project-grid.fo-columns-3,
    .fo-project-grid.fo-columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .fo-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .fo-toolbar-left {
        justify-content: center;
    }

    .fo-toolbar-right {
        justify-content: center;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .fo-project-grid.fo-columns-2,
    .fo-project-grid.fo-columns-3,
    .fo-project-grid.fo-columns-4 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .fo-toolbar-right {
        flex-direction: column;
        width: 100%;
    }

    .fo-search-input {
        width: 100%;
    }

    .fo-sort-control {
        width: 100%;
    }

    .fo-sort-select {
        flex: 1;
    }

    .fo-status-toggle {
        width: 100%;
        justify-content: center;
    }

    .fo-toggle-btn {
        flex: 1;
        text-align: center;
        padding: 8px 10px;
    }

    /* Cards: slightly larger text on mobile for readability */
    .fo-card-title {
        font-size: 1rem;
    }

    .fo-card-subtitle {
        font-size: 0.8125rem;
    }

    .fo-card-detail {
        font-size: 0.8125rem;
    }

    .fo-card-button {
        padding: 10px 16px;
        font-size: 0.875rem;
    }
}

/* Small mobile */
@media (max-width: 400px) {
    .fo-card-documents {
        flex-direction: column;
    }

    .fo-doc-link {
        justify-content: center;
    }
}

/* ===== SINGLE PROJECT VIEW ===== */

.fo-single-container {
    max-width: var(--content-width, 1200px);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

/* Header */
.fo-single-header {
    margin-bottom: 1.75rem;
}

.fo-single-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.fo-single-back {
    font-size: 0.8125rem;
    color: var(--neutral, #61647f);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.fo-single-back:hover {
    color: var(--primary, #e4003a);
}

.fo-single-edit-btn {
    display: inline-block;
    padding: 7px 18px;
    background: var(--primary, #e4003a);
    color: var(--white, #fff) !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(228, 0, 58, 0.2);
}

.fo-single-edit-btn:hover {
    background: var(--secondary, #0e233e);
    box-shadow: 0 2px 8px rgba(14, 35, 62, 0.2);
}

.fo-single-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.fo-single-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--neutral-light, #d8d9e0);
    padding: 4px;
    background: var(--white, #fff);
    box-shadow: 0 1px 3px rgba(14, 35, 62, 0.06);
}

.fo-single-title {
    font-size: var(--h2, 2rem);
    font-weight: var(--heading-font-weight, 900);
    color: var(--base, #0e233e);
    margin: 0;
    line-height: 1.2;
}

.fo-single-subtitle {
    font-size: 1rem;
    color: var(--neutral, #61647f);
    margin: 0.25rem 0 0 0;
}

.fo-single-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.fo-single-meta-item {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--neutral-light, #d8d9e0);
    background: var(--neutral-ultra-light, #f0f1f4);
    color: var(--base, #0e233e);
    transition: transform 0.15s;
}

.fo-single-number {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    letter-spacing: 0.5px;
    background: var(--secondary, #0e233e);
    color: rgba(255, 255, 255, 0.8);
    border-color: var(--secondary, #0e233e);
}

.fo-single-status--active {
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
    border-color: rgba(22, 163, 74, 0.3);
}

.fo-single-status--completed {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    border-color: rgba(107, 114, 128, 0.25);
}

/* Grid for info cards */
.fo-single-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

/* Cards */
.fo-single-card {
    background: var(--white, #fff);
    border: 1px solid var(--neutral-light, #d8d9e0);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(14, 35, 62, 0.04);
    transition: box-shadow 0.2s ease;
}

.fo-single-card:hover {
    box-shadow: 0 2px 8px rgba(14, 35, 62, 0.08);
}

.fo-single-card--full {
    margin-bottom: 1.25rem;
}

.fo-single-card-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--white, #fff);
    background: linear-gradient(135deg, #0e233e 0%, #162d4e 100%);
    padding: 11px 16px;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.fo-single-card-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(228, 0, 58, 0.35), transparent);
}

.fo-single-count {
    font-size: 0.6875rem;
    font-weight: 500;
    opacity: 0.55;
}

/* Definition list */
.fo-single-dl {
    padding: 12px 16px;
    margin: 0;
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0;
}

.fo-single-dl dt {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--neutral, #61647f);
    padding: 6px 0;
    border-bottom: 1px solid #f0f1f4;
}

.fo-single-dl dd {
    font-size: 0.8125rem;
    color: var(--base, #0e233e);
    margin: 0;
    padding: 6px 0;
    border-bottom: 1px solid #f0f1f4;
}

.fo-single-dl dt:last-of-type,
.fo-single-dl dd:last-of-type {
    border-bottom: none;
}

.fo-single-dl dd a {
    color: var(--primary, #e4003a);
    text-decoration: none;
    transition: color 0.15s;
}

.fo-single-dl dd a:hover {
    color: #b00030;
    text-decoration: underline;
}

/* Badge inside dl */
.fo-single-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

/* Documents inside card */
.fo-single-documents {
    padding: 0 16px 14px;
    border-top: 1px solid #f0f1f4;
    margin-top: 4px;
    padding-top: 12px;
}

.fo-single-documents-title {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--neutral, #61647f);
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.fo-single-doc-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.fo-single-documents .fo-doc-link {
    margin-right: 0;
}

.fo-generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--primary, #e4003a);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(228, 0, 58, 0.2);
}

.fo-generate-btn:hover {
    background: #c50030;
    box-shadow: 0 3px 10px rgba(228, 0, 58, 0.25);
    transform: translateY(-1px);
}

.fo-generate-btn:disabled {
    opacity: 0.5;
    cursor: wait;
    transform: none;
    box-shadow: none;
}

.fo-generate-status {
    font-size: 0.75rem;
    margin-left: 8px;
}

.fo-generate-success {
    color: #27a844;
    font-weight: 600;
}

.fo-generate-error {
    color: #e4003a;
    font-weight: 600;
}

/* ===== SITEMAP & ROLES TABLES ===== */
.fo-single-table-wrap {
    overflow-x: auto;
}

.fo-single-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.fo-single-table th {
    text-align: left;
    padding: 9px 12px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--neutral, #61647f);
    background: var(--neutral-ultra-light, #f0f1f4);
    border-bottom: 2px solid var(--neutral-light, #d8d9e0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.fo-single-table td {
    padding: 7px 12px;
    border-bottom: 1px solid #f0f1f4;
    vertical-align: top;
    color: var(--base, #0e233e);
    transition: background 0.1s;
}

.fo-single-table tr:last-child td {
    border-bottom: none;
}

.fo-single-table tbody tr:hover td {
    background: rgba(14, 35, 62, 0.02);
}

.fo-row-section td {
    font-weight: 700;
    background: #f5f6f8 !important;
    border-bottom-color: #e8e9ed;
}

.fo-col-nr {
    width: 36px;
    text-align: center;
    color: var(--neutral, #61647f);
    font-size: 0.75rem;
    font-weight: 500;
}

.fo-col-remarks {
    font-size: 0.75rem;
    color: var(--neutral, #61647f);
    max-width: 300px;
    line-height: 1.45;
}

.fo-tpl-badge {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 7px;
    border-radius: 3px;
    background: #0e233e;
    color: rgba(255, 255, 255, 0.85);
    border: none;
    white-space: nowrap;
}

/* Single Project Responsive */
@media (max-width: 768px) {
    .fo-single-grid {
        grid-template-columns: 1fr;
    }

    .fo-single-dl {
        grid-template-columns: 120px 1fr;
    }

    .fo-single-title {
        font-size: 1.5rem;
    }

    .fo-single-table {
        font-size: 0.75rem;
    }

    .fo-single-table th,
    .fo-single-table td {
        padding: 5px 8px;
    }

    .fo-single-table th {
        position: static;
    }
}
