/* Programs System Styles */

/* Multi-select field (נושא/תוכן, קהל יעד, מקור תקציבי) — Google Sheets lets
   Ortal's team check several list values into one cell for these three
   fields specifically (real data: ~14% of topic cells, ~3% of audience,
   ~1.5% of budget source). A hidden input carries the comma-joined value
   under the real field name so the existing FormData-based save flow needs
   no changes; the checkboxes are purely a display/edit affordance on top. */
.multi-select-wrap {
    position: relative;
}

.multi-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
    min-height: 20px;
}

.multi-select-trigger:hover {
    border-color: var(--text3);
}

.multi-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    z-index: 50;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.multi-select-option:hover {
    background: var(--bg2);
}

/* View mode switch (רשימה / דשבורד) — deliberately higher-contrast than the
   .prog-tab underline style used inside the program-details modal, since
   this one needs to be noticed at a glance on first load. */
.view-mode-switch {
    display: inline-flex;
    background: var(--bg2);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.view-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text3);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.view-mode-btn:hover {
    color: var(--text);
}

.view-mode-btn.active {
    background: linear-gradient(135deg, #006838, #8DC63F);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 104, 56, 0.25);
}

.programs-table {
    width: auto;
    min-width: 100%;
    border-collapse: collapse;
    background: transparent;
    table-layout: auto;
}

/* #programsTable (the main "רשימה" list) now shows every column, on purpose
   (Nadav wants everything visible with horizontal scroll rather than a
   curated subset) — the wrapping div has overflow-x:auto for that. First
   few special columns (id/status/warming) keep fixed pixel widths; every
   other column gets a shared max-width below so one long free-text field
   (הערות, פרטי איש קשר) can't balloon the whole table. */
#programsTable th:nth-child(1) { width: 35px; }  /* # */
#programsTable th:nth-child(3) { width: 50px; }  /* התחממות */
#programsTable th:last-child,
#programsTable td:last-child   { width: 70px; }  /* פעולות */
#programsTable thead tr:last-child th:first-child { width: 110px; } /* סטטוס — sits alone in the second header row, see buildUI() */

#programsTable th,
#programsTable td {
    max-width: 200px;
}

/* Group header row (בסיס/מכירות/גיוס/...) — mirrors the program-details
   modal's tabs and the Excel sheet's own section headers, so the ~100
   columns read as chunks instead of one flat wall. Clickable: collapses to
   colspan=1 (see Programs.toggleGroup) so a whole section can be hidden
   until it's actually needed for that meeting. */
.prog-group-header {
    text-align: center !important;
    background: #cbd5e1 !important;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    user-select: none;
    white-space: nowrap !important;
}

.prog-group-header:hover {
    background: #b8c4d6 !important;
}

.programs-table th {
    background: #e2e8f0;
    color: var(--text2);
    font-weight: 600;
    padding: 0.5rem 0.4rem;
    text-align: right;
    font-size: 0.7rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: middle;
}

.programs-table td {
    padding: 0.4rem 0.4rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.programs-table tbody tr {
    background: #f8fafc;
}

.programs-table tbody tr:nth-child(even) {
    background: #f1f5f9;
}

.programs-table tbody tr:hover {
    background: #e2e8f0;
    transition: background 0.2s ease;
}

.prog-status-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
}

.prog-status-1 { background: #64748b; }
.prog-status-2 { background: #f59e0b; }
.prog-status-3 { background: #3b82f6; }
.prog-status-4 { background: #8b5cf6; }
.prog-status-5 { background: #10b981; }
.prog-status-6 { background: #6b7280; }
.prog-status-7 { background: #ef4444; }

/* Program Details Modal */
.program-details-modal {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.program-details-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
}

.program-details-modal .modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

.program-details-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text3);
    line-height: 1;
}

.program-details-modal .modal-close:hover {
    color: var(--danger);
}

.program-details-modal .modal-body {
    padding: 1.5rem;
}

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

.details-section {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border);
}

.details-section.full-width {
    grid-column: 1 / -1;
}

.details-section h3 {
    margin: 0 0 0.8rem 0;
    font-size: 0.95rem;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
}

/* Flat horizontal layout for tab content */
.prog-tab-content .details-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
}

.prog-tab-content .details-section {
    background: none;
    border: none;
    padding: 0;
    display: contents;
}

.prog-tab-content .details-section h3 {
    grid-column: 1 / -1;
    margin: 0.5rem 0 0.2rem;
    font-size: 0.85rem;
}

.prog-tab-content .details-section.full-width {
    display: contents;
}

.prog-tab-content .form-group {
    margin-bottom: 0;
}

.prog-tab-content .form-textarea {
    min-height: 60px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px dashed var(--border);
}

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

.detail-row .label {
    font-weight: 500;
    color: var(--text2);
    font-size: 0.85rem;
}

.detail-row .value {
    color: var(--text);
    font-size: 0.9rem;
    text-align: left;
}

.notes-content {
    background: var(--card);
    padding: 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Program Tabs */
.prog-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text3);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.prog-tab:hover {
    color: var(--text);
    background: var(--bg);
}

.prog-tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
    font-weight: 600;
}

.prog-tab-content {
    padding: 0.5rem 0;
}

.program-details-modal .modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Stats bar gray color */
.stat-value.gray {
    color: #6b7280;
}

/* Table container */
#programsSystem .table-container {
    background: #f8fafc;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* Form styles for modal */
.form-group {
    margin-bottom: 0.8rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--card);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-input:hover {
    border-color: var(--text3);
}

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

select.form-input {
    cursor: pointer;
}

/* Button primary style */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark, #16a34a);
}

/* Make modal wider for edit form */
.program-details-modal {
    max-width: 1000px;
}

/* Programs Header - Smaller buttons */
#programsSystem .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

#programsSystem .header h1 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

#programsSystem .header-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

#programsSystem .header-right .btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* ========================================
   Programs Filters - Compact Layout
   ======================================== */
#programsSystem .filters-section {
    padding: 0.75rem 1rem;
}

#programsSystem .filters-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#programsSystem .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

#programsSystem .filter-label {
    font-size: 0.7rem;
}

#programsSystem .filter-input,
#programsSystem .filter-select {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    min-width: 100px;
    height: 32px;
}

#programsSystem .btn-show,
#programsSystem .btn-reset {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    height: 32px;
}

#programsSystem .filtered-count {
    font-size: 0.75rem;
    color: var(--text3);
    white-space: nowrap;
}

/* ========================================
   Import Modal Styles
   ======================================== */
.import-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.import-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text3);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s;
    font-family: inherit;
}

.import-tab:hover {
    background: var(--bg);
    color: var(--text);
}

.import-tab.active {
    background: var(--primary);
    color: white;
}

.import-section {
    min-height: 180px;
}

.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
}

.file-upload-area:hover {
    border-color: var(--primary);
    background: rgba(34, 197, 94, 0.05);
}

.file-upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.file-upload-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.file-upload-hint {
    font-size: 0.8rem;
    color: var(--text3);
}

.selected-file-name {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 6px;
    color: var(--primary);
    font-weight: 500;
    text-align: center;
}

/* ========================================
   Action Buttons in Table
   ======================================== */
.action-buttons {
    display: flex;
    flex-direction: row !important;
    gap: 0.3rem;
    justify-content: center;
    align-items: center;
}

.btn-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.75rem !important;
    min-width: 28px;
    height: 26px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fecaca;
    color: #b91c1c;
}

/* ========================================
   Import Preview
   ======================================== */
.import-preview {
    margin-top: 1rem;
}

.import-instructions {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.import-instructions p {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.import-instructions p:last-child {
    margin-bottom: 0;
}

.import-note {
    font-size: 0.8rem !important;
    color: #059669;
}

/* ── Milestones tab ─────────────────────────────────────────────────────── */
.ms-section {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
}

.ms-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ms-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: background 0.15s;
}

.ms-item:hover {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.ms-item.ms-done {
    background: #f0fdf4;
    border-color: #86efac;
    opacity: 0.7;
}

.ms-item.ms-done .ms-label {
    text-decoration: line-through;
    color: #94a3b8;
}

.ms-label {
    font-size: 0.87rem;
    font-weight: 500;
    color: #1e293b;
    transition: color 0.15s;
}
