/* ============================================================
   JSA Form Stylesheet
   File: css/style.css
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@page {
    size: letter;
    margin: 0.3in;
}

body {
    font-family: Arial, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    background: #f8f9fa;
    padding: 20px;
}

.container {
    max-width: 8.5in;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.page {
    padding: 0.4in;
    min-height: 10.5in;
    background: white;
}

.page:first-child {
    border-bottom: 2px dashed #ccc;
}

/* ── Headings ── */
h1 {
    text-align: center;
    color: #1a1a1a;
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: bold;
    border-bottom: 3px solid #2c5aa0;
    padding-bottom: 6px;
    letter-spacing: 1px;
}

h2 {
    color: #fff;
    margin-top: 10px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: bold;
    border-bottom: 2px solid #2c5aa0;
    padding: 4px 8px;
    background: linear-gradient(135deg, #2c5aa0 0%, #1e4070 100%);
    border-radius: 3px;
    letter-spacing: 0.5px;
}

h2.h2-incident {
    color: orange;
    background: linear-gradient(135deg, #394563 10%, #7190BD 100%);
}

h2.h2-sig {
    margin-top: 0;
    background: transparent;
    color: #2c5aa0;
    border-bottom: 2px solid #2c5aa0;
    padding: 4px 0;
}

/* ── Form Layout ── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.form-group {
    margin-bottom: 6px;
}

.form-group.full-width  { grid-column: 1 / -1; }
.form-group.half-width  { grid-column: span 2; }

label {
    display: block;
    margin-bottom: 3px;
    color: #2c3e50;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
}

/* ── Inputs ── */
input[type="text"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="tel"],
textarea {
    width: 100%;
    padding: 5px 8px;
    border: 1.5px solid #cbd5e0;
    font-size: 12px;
    background: #f8fafc;
    color: #1a1a1a;
    border-radius: 3px;
    transition: all 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="tel"]:focus,
textarea:focus {
    outline: none;
    border-color: #2c5aa0;
    background: white;
    box-shadow: 0 0 0 3px rgba(44,90,160,0.1);
}

textarea {
    resize: vertical;
    min-height: 32px;
    height: 32px;
}

/* ── Checkboxes & Radios ── */
.checkbox-group,
.radio-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 10px;
    margin-top: 6px;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    padding: 3px;
    border-radius: 3px;
    transition: background 0.2s;
}

.checkbox-item:hover,
.radio-item:hover {
    background: #e8f0ff;
}

input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #2c5aa0;
}

input[type="checkbox"]:checked + *,
input[type="radio"]:checked + * {
    font-weight: bold;
    color: #1a1a1a;
}

.yes-no {
    display: inline-flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Section Boxes ── */
.section-box {
    border: 1.5px solid #cbd5e0;
    padding: 8px;
    margin: 6px 0;
    border-radius: 4px;
    background: #f8fafc;
}

.inline-group {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.compact-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 6px;
}

.three-col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.three-col .yes-no      { display: flex !important; gap: 5px; flex-wrap: wrap; }
.three-col .radio-item  { white-space: nowrap; }

/* ── Buttons ── */
button[type="submit"] {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e4070 100%);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    letter-spacing: 0.5px;
    transition: all 0.3s;
}

button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44,90,160,0.4);
}

.mark-na-btn {
    background: #6c757d;
    color: white;
    padding: 4px 12px;
    border: none;
    border-radius: 3px;
    font-size: 9px;
    cursor: pointer;
    margin-bottom: 6px;
    transition: all 0.2s;
}

.mark-na-btn:hover {
    background: #5a6268;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.weather-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 9px;
    cursor: pointer;
    font-weight: 600;
    margin-left: 5px;
    transition: background 0.2s;
}

.weather-btn:hover {
    background: #138496;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ── Signature Section ── */
.signature-section {
    margin-top: 10px;
    padding: 8px;
    border: 2px solid #2c5aa0;
    border-radius: 4px;
    background: #f8fafc;
}

.signature-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 8px;
}

/* ── Stylus / Touch Signature Pads ── */
.sig-pad-wrapper {
    position: relative;
    border: 1.5px solid #2c5aa0;
    border-radius: 4px;
    background: white;
    touch-action: none; /* prevent scroll while drawing */
}

.sig-canvas {
    display: block;
    width: 100%;
    height: 80px;
    cursor: crosshair;
    border-radius: 3px 3px 0 0;
    touch-action: none;
}

.sig-canvas.active {
    background: #fffef5;
}

.sig-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 6px;
    background: #f0f4ff;
    border-top: 1px solid #cbd5e0;
    border-radius: 0 0 3px 3px;
}

.sig-clear-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 9px;
    cursor: pointer;
    transition: background 0.2s;
}

.sig-clear-btn:hover {
    background: #b02a37;
}

.sig-hint {
    font-size: 9px;
    color: #6c757d;
    font-style: italic;
}

/* ── Crew Signature Grid ── */
.crew-grid {
    display: grid;
    grid-template-columns: 2fr 5fr 1fr;
    border: 2px solid #2c5aa0;
    background: white;
}

.crew-header {
    font-weight: bold;
    font-size: 9px;
    border-bottom: 2px solid #2c5aa0;
    padding: 6px;
    background: #e8f0ff;
}

.crew-header:not(:last-child) {
    border-right: 1px solid #cbd5e0;
}

.crew-cell {
    border-bottom: 1px solid #e0e0e0;
    padding: 4px;
    min-height: 90px;
    position: relative;
}

.crew-cell:not(:last-child) {
    border-right: 1px solid #e0e0e0;
}

.crew-cell input[type="text"] {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 12px;
    padding: 2px 4px;
    height: 28px;
}

.crew-cell input[type="text"]:focus {
    outline: 1px solid #2c5aa0;
    border-radius: 2px;
    background: #fffef5;
    box-shadow: none;
}

.crew-sig-canvas {
    display: block;
    width: 100%;
    height: 82px;
    cursor: crosshair;
    touch-action: none;
    border-radius: 2px;
}

.crew-initials-canvas {
    display: block;
    width: 100%;
    height: 82px;
    cursor: crosshair;
    touch-action: none;
    border-radius: 2px;
}

.crew-clear-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220, 53, 69, 0.75);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 8px;
    padding: 1px 5px;
    cursor: pointer;
    line-height: 1.4;
    z-index: 10;
    transition: background 0.2s;
}

.crew-clear-btn:hover {
    background: rgba(176, 42, 55, 0.95);
}
@media screen and (max-width: 900px) {
    body { padding: 10px; }
    .form-row     { grid-template-columns: 1fr 1fr; }
    .three-col    { grid-template-columns: 1fr; }
    .signature-row { grid-template-columns: 1fr; }
    .crew-grid    { grid-template-columns: 1fr 2fr 1fr; }
}

/* ── Print ── */
@media print {
    body {
        background: white;
        padding: 0;
        font-size: 7px;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .container { box-shadow: none; max-width: 100%; }

    .page {
        page-break-after: always;
        page-break-inside: avoid;
        padding: 0.25in;
        min-height: 0;
    }

    .page:last-child  { page-break-after: auto; }
    .page:first-child { border-bottom: none; }

    h1 { font-size: 13px; margin-bottom: 6px; padding-bottom: 3px; }
    h2 { font-size: 8px; margin-top: 4px; margin-bottom: 3px; padding: 2px 4px; }
    label { font-size: 6.5px; margin-bottom: 1px; }

    input, textarea {
        font-size: 7px;
        padding: 1px 2px;
        border: 1px solid #000;
    }

    textarea { min-height: 18px; height: 18px; }

    .checkbox-item,
    .radio-item { font-size: 6.5px; padding: 1px; }

    input[type="checkbox"],
    input[type="radio"] { width: 9px; height: 9px; }

    button, .mark-na-btn, .sig-clear-btn, .sig-hint,
    .weather-btn { display: none; }

    .form-row    { gap: 3px; margin-bottom: 3px; }
    .compact-row { gap: 6px; margin-bottom: 3px; }
    .three-col   { gap: 4px; }

    .checkbox-group,
    .radio-group { gap: 1px 6px; margin-top: 2px; }

    .section-box {
        padding: 3px;
        margin: 2px 0;
        border: 1px solid #000;
    }

    .signature-section {
        margin-top: 4px;
        padding: 3px;
        border: 1.5px solid #000;
    }

    .signature-row { gap: 6px; margin-bottom: 3px; }
    .inline-group  { gap: 8px; }

    /* Show canvas drawings when printing */
    .sig-canvas, .crew-sig-canvas {
        display: block;
        border: 1px solid #999;
    }
    .sig-pad-wrapper { border: 1px solid #000; }
}

/* ── iOS PWA Keyboard Fix ── */
/* Prevents Safari from stacking multiple keyboards in standalone mode */
@media (display-mode: standalone) {
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* ── Lists and Bullets ── */
.load-roster-btn {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    color: white;
    border: none;
    padding: 7px 16px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.load-roster-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(40,167,69,0.3);
}

@media print {
    .load-roster-btn { display: none; }
}
