/* Shared components: the status pill, the task card, the modal and the form
   controls. Loaded by every page, after base.css.
   These are shared on purpose -- the task card is rendered by the member
   dashboard (checklist-view.js) and by the admin's tasks.html and
   checklist-edit.html, and admin.css extends .status-badge rather than
   redefining it. Changing a rule here affects all of them. */

/* Status pills read like a departures board: small, spaced capitals. The text
   comes from the status value ("in progress"), which the transform shouts. */
.status-badge {
    display: inline-flex;
    padding: 3px 9px;
    border-radius: 5px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    background: var(--sky);
    color: var(--text-muted);
}

.status-pending {
    color: #805915;
    background: var(--warning-soft);
}

.status-in_progress {
    color: var(--instrument-blue);
    background: var(--accent-soft);
}

.status-completed {
    color: var(--starboard-green);
    background: var(--success-soft);
}

.tasks-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* The thicker left edge is a boarding-pass stub: grey until the task is signed
   off, then starboard green */
.task-card {
    background: white;
    border: 1px solid var(--panel-line);
    border-radius: var(--radius-card);
    padding: 24px;
}

.task-card.completed {
    border-color: #b9d9c8;
    background: white;
}

.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--panel-line);
}

.task-title {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

/* Set like an aircraft type code on a manifest */
.task-type {
    background: var(--sky);
    color: var(--text-muted);
    padding: 3px 8px;
    border-radius: var(--radius-control);
    font-size: 0.75rem;
}

.task-optional {
    margin-left: 8px;
    background: var(--sky);
    color: var(--text-muted);
    padding: 3px 8px;
    border-radius: var(--radius-control);
    font-size: 0.75rem;
}

.task-description {
    color: #6b7280;
    margin-bottom: 1rem;
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.task-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.task-status.completed {
    color: var(--starboard-green);
}

/* The status sits inline with the buttons in the task actions row */
.task-actions .task-status {
    margin-top: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: var(--radius-card);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem 2rem 1rem 2rem;
    border-bottom: 1px solid #e5e7eb;
    flex: 0 0 auto;
}

.modal-body {
    padding: 1rem 2rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    scroll-behavior: smooth;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: var(--radius-control);
}

.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: var(--radius-control);
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Ensure forms within modal body don't interfere with scrolling */
.modal-body form {
    min-height: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body .form-group {
    flex: 0 0 auto;
}

.modal-body .config-section {
    flex: 0 0 auto;
}

.modal-footer {
    padding: 1rem 2rem 1.5rem 2rem;
    border-top: 1px solid #e5e7eb;
    flex: 0 0 auto;
    background-color: white;
    border-radius: 0 0 8px 8px;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.close:hover {
    color: #000;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--panel-line);
    border-radius: var(--radius-control);
    font-size: 0.95rem;
}

/* The width above is meant for the text-like controls: a checkbox or a radio is a
   fixed-size box, and stretching it across the row pushes its label away. */
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--instrument-blue);
    box-shadow: 0 0 0 3px rgba(27, 79, 138, 0.12);
}

.file-upload {
    border: 2px dashed #d1d5db;
    border-radius: 6px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload:hover,
.file-upload.dragover {
    border-color: var(--instrument-blue);
    background: #f0f6fc;
}

/* A file is attached: solid instead of dashed, and tinted starboard green so
   "selected" reads the same as "done" everywhere else in the app. */
.file-upload.has-file {
    border-style: solid;
    border-color: var(--starboard-green);
    background: rgba(5, 150, 105, 0.06);
}

.file-upload.has-file:hover {
    background: rgba(5, 150, 105, 0.1);
}

.file-upload-selected {
    font-family: var(--instrument-font);
    color: var(--starboard-green);
    font-weight: 600;
    word-break: break-word;
}

.file-upload input[type="file"] {
    display: none;
}

/* Checklist Styles */
.checklist-items {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem;
    background: #f9fafb;
}

.checklist-item {
    margin-bottom: 0.5rem;
}

.checklist-item:last-child {
    margin-bottom: 0;
}

.checkbox-label, .radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-control);
    transition: background-color 0.2s;
}

.checkbox-label:hover, .radio-label:hover {
    background: #f3f4f6;
}

.checkbox-label input[type="checkbox"],
.checkbox-label input[type="radio"],
.radio-label input[type="checkbox"],
.radio-label input[type="radio"] {
    margin-right: 0.5rem;
    margin-left: 0;
}

.checkbox-label span, .radio-label span {
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        padding: 0;
    }
}
