/**
 * Requirements Management Styles - Complete
 * Modern sidebar layout with modal creation form
 */

/* Page Header */
.requirements-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.requirements-page-header h2 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    color: #333;
}

.requirements-page-header .subtitle {
    margin: 0;
    color: #666;
    font-size: 1rem;
}

/* Main Layout - Sidebar + Detail Panel */
.requirements-container {
    display: flex;
    height: calc(100vh - 250px);
    min-height: 600px;
    gap: 0;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ===================================
   SIDEBAR
   =================================== */
.requirements-sidebar {
    width: 340px;
    background: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

/* Sort controls injected by requirement-builder.js into the sidebar header. */
.req-sort-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}
.req-sort-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    font-weight: 600;
    margin-right: 2px;
}
.req-sort-btn {
    font-size: 0.78rem;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid #d0d7e0;
    background: #fff;
    color: #475569;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.req-sort-btn:hover {
    background: #f1f5f9;
}
.req-sort-btn.req-sort-active {
    background: #2175d9;
    border-color: #2175d9;
    color: #fff;
}

.sidebar-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: #999;
}

.sidebar-empty p {
    margin: 0.5rem 0;
}

.sidebar-empty .text-muted {
    font-size: 0.9rem;
}

/* Sidebar Requirement Cards */
.requirement-sidebar-card {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    position: relative;
}

.requirement-sidebar-card:hover {
    background: #f8f9fa;
}

.requirement-sidebar-card.selected {
    background: #e3f2fd;
    border-left: 4px solid #2196F3;
    padding-left: calc(1.5rem - 4px);
}

.requirement-sidebar-card.selected::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #2196F3, #1976D2);
}

.card-header-mini {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.card-header-mini h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    flex: 1;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    gap: 0.5rem;
}

.card-footer-mini {
    font-size: 0.75rem;
    color: #999;
}

/* Status Pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 14px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-pill.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-pill.inactive {
    background: #f5f5f5;
    color: #757575;
}

/* Type Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.badge.type-EU_TENDER {
    background: #e3f2fd;
    color: #1565c0;
}

.badge.type-BE_TENDER {
    background: #fff3e0;
    color: #e65100;
}

.badge.type-BE_DIRECT {
    background: #fce4ec;
    color: #ad1457;
}

/* ===================================
   DETAIL PANEL
   =================================== */
.requirement-detail-panel {
    flex: 1;
    background: white;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.detail-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.header-title h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.detail-body {
    padding: 2rem;
    flex: 1;
}

/* Info Sections */
.info-section {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.info-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.info-section h4 {
    margin: 0 0 1.25rem 0;
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.info-item label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item div {
    font-size: 1rem;
    color: #333;
}

.info-item code {
    background: #f5f5f5;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.9rem;
    color: #d32f2f;
}

.requirement-text {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 6px;
    white-space: pre-wrap;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.7;
    color: #333;
    border: 1px solid #e0e0e0;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.draft {
    background: #f5f5f5;
    color: #666;
}

.status-badge.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.inactive {
    background: #f5f5f5;
    color: #757575;
}

.status-badge.parsing,
.status-badge.unparsed {
    background: #fff3e0;
    color: #f57c00;
}

.status-badge.parsed,
.status-badge.ready {
    background: #e3f2fd;
    color: #1565c0;
}

.status-badge.error {
    background: #ffebee;
    color: #c62828;
}

/* JSON Display */
.json-display {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    margin-top: 1rem;
    border: 1px solid #e0e0e0;
    max-height: 500px;
}

details summary {
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

details summary:hover {
    color: #2196F3;
}

details[open] summary {
    margin-bottom: 1rem;
}

/* ===================================
   FORMS
   =================================== */
.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h4 {
    margin: 0 0 1.5rem 0;
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.5rem;
}

.form-group small {
    display: block;
    margin-top: 0.4rem;
    color: #666;
    font-size: 0.85rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-control:disabled {
    background: #f5f5f5;
    color: #666;
    cursor: not-allowed;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.radio-option {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: flex-start;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-option:hover {
    border-color: #2196F3;
    background: #f5f5f5;
}

.radio-option input[type="radio"]:checked + .radio-label {
    color: #2196F3;
}

.radio-option input[type="radio"] {
    margin-top: 0.25rem;
    margin-right: 0.75rem;
    cursor: pointer;
}

.radio-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.radio-label strong {
    font-size: 1rem;
}

.radio-label small {
    color: #666;
    font-size: 0.875rem;
}

/* ===================================
   BUTTONS
   =================================== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn svg {
    flex-shrink: 0;
}

.btn-primary {
    background: #2196F3;
    color: white;
}

.btn-primary:hover {
    background: #1976D2;
}

.btn-secondary {
    background: #757575;
    color: white;
}

.btn-secondary:hover {
    background: #616161;
}

.btn-outline {
    background: white;
    color: #2196F3;
    border: 2px solid #2196F3;
}

.btn-outline:hover {
    background: #2196F3;
    color: white;
}

.btn-danger {
    background: #d32f2f !important;
    color: #ffffff !important;
}

.btn-danger:hover {
    background: #b71c1c !important;
    color: #ffffff !important;
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #388e3c;
}

/* ===================================
   MODAL
   =================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease-out;
}

.modal-content.modal-medium {
    max-width: 700px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
}

.close-btn {
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid #f0f0f0;
}

/* ===================================
   EMPTY STATE
   =================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: #999;
    text-align: center;
    padding: 3rem;
}

.empty-state svg {
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin: 0 0 0.75rem 0;
    color: #999;
    font-weight: 500;
    font-size: 1.5rem;
}

.empty-state p {
    margin: 0;
    font-size: 1rem;
    color: #bbb;
}

/* ===================================
   UTILITIES
   =================================== */
.text-muted {
    color: #666 !important;
}

.hidden {
    display: none !important;
}

/* ===================================
   SCROLLBAR STYLING
   =================================== */
.requirements-sidebar::-webkit-scrollbar,
.requirement-detail-panel::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.requirements-sidebar::-webkit-scrollbar-track,
.requirement-detail-panel::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.requirements-sidebar::-webkit-scrollbar-thumb,
.requirement-detail-panel::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 4px;
}

.requirements-sidebar::-webkit-scrollbar-thumb:hover,
.requirement-detail-panel::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 1200px) {
    .requirements-sidebar {
        width: 300px;
    }
}

@media (max-width: 1024px) {
    .requirements-sidebar {
        width: 280px;
    }

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

    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions .btn {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .requirements-container {
        flex-direction: column;
        height: auto;
    }

    .requirements-sidebar {
        width: 100%;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .requirement-detail-panel {
        min-height: 400px;
    }

    .requirements-page-header {
        flex-direction: column;
        gap: 1rem;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .radio-group {
        flex-direction: column;
    }

    .radio-option {
        min-width: 0;
    }
}

/* ============================================================
   Dark-mode overrides for requirements surfaces.
   requirements-styles.css ships with light-mode hardcoded values.
   These overrides flip the requirements layout (sidebar, detail
   panel, form inputs) to dark equivalents while preserving
   semantic colors (validation reds, success greens, status pills,
   pastel callouts) as raw literals.
   ============================================================ */
[data-theme="dark"] .requirements-container,
[data-theme="dark"] .requirements-layout {
    background-color: #0f172a;
}

[data-theme="dark"] .requirements-sidebar {
    background-color: #1e293b;
    border-right-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .sidebar-header {
    background-color: #1e293b;
    border-bottom-color: #334155;
}

[data-theme="dark"] .sidebar-header h3,
[data-theme="dark"] .requirement-item,
[data-theme="dark"] .requirement-detail {
    color: #f1f5f9;
}

[data-theme="dark"] .requirement-item {
    background-color: transparent;
    border-bottom-color: #334155;
}

[data-theme="dark"] .requirement-item:hover,
[data-theme="dark"] .requirement-item.active {
    background-color: #243549;
}

[data-theme="dark"] .requirement-detail,
[data-theme="dark"] .detail-panel,
[data-theme="dark"] .req-detail-content,
[data-theme="dark"] .req-section,
[data-theme="dark"] .basic-info-grid,
[data-theme="dark"] .req-form-section {
    background-color: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .req-detail-content h2,
[data-theme="dark"] .req-detail-content h3,
[data-theme="dark"] .req-section h3,
[data-theme="dark"] .req-section-title {
    color: #f1f5f9;
}

[data-theme="dark"] .basic-info-grid .info-label,
[data-theme="dark"] .req-section .label,
[data-theme="dark"] .req-meta {
    color: #94a3b8;
}

[data-theme="dark"] .basic-info-grid .info-value,
[data-theme="dark"] .req-section .value {
    color: #f1f5f9;
}

[data-theme="dark"] .req-text-content,
[data-theme="dark"] .requirement-text-display {
    background-color: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}

/* Form inputs in dark mode */
[data-theme="dark"] .req-form input[type="text"],
[data-theme="dark"] .req-form input[type="email"],
[data-theme="dark"] .req-form textarea,
[data-theme="dark"] .req-form select {
    background-color: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}

[data-theme="dark"] .req-form input:focus,
[data-theme="dark"] .req-form textarea:focus,
[data-theme="dark"] .req-form select:focus {
    border-color: #2175d9;
    background-color: #0f172a;
}

[data-theme="dark"] .req-form label {
    color: #cbd5e1;
}

/* Sticky headers in dark */
[data-theme="dark"] .req-detail-header {
    background-color: #1e293b;
    border-bottom-color: #334155;
}

/* Empty state */
[data-theme="dark"] .no-requirements,
[data-theme="dark"] .empty-state {
    color: #94a3b8;
}

/* ============================================================
   Dark-mode overrides — corrected selectors for actual classes
   used by the requirements markup (.requirements-page-header,
   .requirement-sidebar-card, .requirement-detail-panel,
   .detail-header, .detail-body, .info-section, .info-grid,
   .info-item, .requirement-text, .form-section).
   ============================================================ */

/* Page header */
[data-theme="dark"] .requirements-page-header h2 {
    color: #f1f5f9;
}
[data-theme="dark"] .requirements-page-header .subtitle {
    color: #94a3b8;
}

/* Sidebar cards (the requirement entries on the left) */
[data-theme="dark"] .requirement-sidebar-card {
    background-color: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}
[data-theme="dark"] .requirement-sidebar-card:hover {
    background-color: #243549;
}
[data-theme="dark"] .requirement-sidebar-card.selected {
    background-color: #243549;
    border-color: #2175d9;
}
[data-theme="dark"] .card-header-mini h5,
[data-theme="dark"] .card-meta {
    color: #f1f5f9;
}
[data-theme="dark"] .card-meta {
    color: #94a3b8;
}
[data-theme="dark"] .card-footer-mini {
    color: #94a3b8;
}
[data-theme="dark"] .sidebar-empty,
[data-theme="dark"] .sidebar-empty .text-muted {
    color: #94a3b8;
}

/* Right detail panel — the big stuck-light surface */
[data-theme="dark"] .requirement-detail-panel {
    background-color: #1e293b;
    color: #f1f5f9;
}
[data-theme="dark"] .detail-header {
    background-color: #1e293b;
    border-bottom-color: #334155;
}
[data-theme="dark"] .detail-body {
    background-color: #1e293b;
    color: #f1f5f9;
}
[data-theme="dark"] .header-title h3 {
    color: #f1f5f9;
}

/* Info section blocks (Basic Information, etc.) */
[data-theme="dark"] .info-section {
    background-color: transparent;
    border-color: #334155;
}
[data-theme="dark"] .info-section h4 {
    color: #f1f5f9;
}
[data-theme="dark"] .info-grid {
    background-color: transparent;
}
[data-theme="dark"] .info-item label {
    color: #94a3b8;
}
[data-theme="dark"] .info-item div {
    color: #f1f5f9;
}
[data-theme="dark"] .info-item code {
    background-color: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}

/* Requirement text display block */
[data-theme="dark"] .requirement-text {
    background-color: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}

/* JSON display */
[data-theme="dark"] .json-display {
    background-color: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}

/* Form sections (new requirement / edit requirement) */
[data-theme="dark"] .form-section {
    background-color: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .form-section h4 {
    color: #f1f5f9;
}

