/* ============================================================
   mie-checks.css  –  MIE Checks Invoice  (Agile Automate)
   All colours via --app-* variables from central.css
   ============================================================ */

/* ── Container ─────────────────────────────────────────────── */
.mie-container {
    max-width: 1140px;
    margin: 24px auto 60px;
    padding: 0 20px;
    font-family: var(--app-font-family, "Segoe UI", Tahoma, Arial, sans-serif);
    color: var(--app-text, #1e293b);
}

/* ── Phase Selector Card ────────────────────────────────────── */
.phase-card {
    background: linear-gradient(135deg, var(--app-button-bg, #2A54B1) 0%, var(--app-button-bg-alt, #1e3f85) 100%);
    border-radius: var(--app-radius, 12px);
    padding: 22px 24px;
    margin-bottom: 24px;
    box-shadow: var(--app-shadow, 0 8px 24px rgba(31,41,55,0.12));
    display: flex;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.phase-card .phase-select-wrap {
    flex: 1;
    min-width: 220px;
}

.phase-card .phase-select-wrap label {
    display: block;
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.phase-card .phase-select-wrap label i {
    margin-right: 7px;
    opacity: 0.85;
}

.phase-card select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    background: #fff;
    color: var(--app-text, #1e293b);
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    outline: none;
    transition: box-shadow 0.2s;
}

.phase-card select:focus {
    box-shadow: 0 0 0 3px rgba(255,255,255,0.4);
}

.phase-card .phase-guidelines {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 14px 18px;
    color: rgba(255,255,255,0.95);
    font-size: 12.5px;
    line-height: 1.7;
    flex: 1;
    min-width: 260px;
}

.phase-card .phase-guidelines strong {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}

/* ── Invoice Meta (Bill To + Candidate) ─────────────────────── */
.invoice-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.meta-block {
    background: var(--app-panel-bg, #fff);
    border: 1px solid var(--app-line, #e2e8f0);
    border-radius: var(--app-radius, 12px);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(31,41,55,0.06);
}

.meta-block-header {
    background: var(--app-table-head-bg, #2A54B1);
    color: var(--app-table-head-text, #fff);
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-block-body {
    padding: 16px 18px;
}

.meta-block textarea {
    width: 100%;
    border: 1px solid var(--app-line, #e2e8f0);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--app-text, #1e293b);
    background: var(--app-bg, #f8fafc);
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 110px;
    box-sizing: border-box;
}

.meta-block textarea:focus {
    outline: none;
    border-color: var(--app-button-bg, #2A54B1);
    box-shadow: 0 0 0 3px rgba(42,84,177,0.12);
    background: #fff;
}

.candidate-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.candidate-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--app-muted, #6b7280);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.candidate-grid input {
    padding: 8px 11px;
    border: 1px solid var(--app-line, #e2e8f0);
    border-radius: 7px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--app-text, #1e293b);
    background: var(--app-bg, #f8fafc);
    box-sizing: border-box;
}

.candidate-grid input:disabled {
    background: #f1f5f9;
    color: #475569;
    cursor: default;
    border-color: #e2e8f0;
}

/* ── Checks Table Card ──────────────────────────────────────── */
.checks-card {
    background: var(--app-panel-bg, #fff);
    border: 1px solid var(--app-line, #e2e8f0);
    border-radius: var(--app-radius, 12px);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(31,41,55,0.06);
    margin-bottom: 20px;
}

.checks-card-header {
    background: var(--app-table-head-bg, #2A54B1);
    color: var(--app-table-head-text, #fff);
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 9px;
}

.mie-table-wrap {
    overflow-x: auto;
}

.mie-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    min-width: 680px;
}

.mie-table thead th {
    background: #f8fafc;
    color: #334155;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 14px;
    border-bottom: 2px solid var(--app-line, #e2e8f0);
    white-space: nowrap;
}

.mie-table thead th:first-child {
    text-align: center;
    width: 52px;
}

.mie-table tbody tr {
    transition: background 0.15s;
}

.mie-table tbody tr:hover {
    background: #f0f6ff;
}

.mie-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--app-line, #e2e8f0);
    vertical-align: middle;
    color: var(--app-text, #1e293b);
}

.mie-table tbody td:first-child {
    text-align: center;
}

.mie-table tbody tr:last-child td {
    border-bottom: none;
}

/* Checkbox in table */
.mie-table input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--app-button-bg, #2A54B1);
    cursor: pointer;
}

/* Money inputs in table cells */
.mie-table .money {
    width: 90px;
    padding: 6px 10px;
    border: 1px solid var(--app-line, #e2e8f0);
    border-radius: 6px;
    font-size: 13px;
    font-family: "Courier New", monospace;
    text-align: right;
    background: #f8fafc;
    color: var(--app-text, #1e293b);
}

.mie-table .money:disabled {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}

/* tfoot totals row */
.mie-table tfoot tr {
    background: #f1f5f9;
}

.mie-table tfoot td {
    padding: 11px 14px;
    border-top: 2px solid var(--app-line, #e2e8f0);
    font-weight: 700;
    font-size: 13px;
    color: var(--app-text, #1e293b);
}

.mie-table tfoot .right {
    text-align: right;
    color: var(--app-button-bg, #2A54B1);
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Status badges inside table */
.mie-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.mie-status-badge.clear,
.mie-status-badge.passed {
    background: #dcfce7;
    color: #15803d;
}

.mie-status-badge.pending,
.mie-status-badge.in-progress {
    background: #fef9c3;
    color: #92400e;
}

.mie-status-badge.failed,
.mie-status-badge.rejected {
    background: #fee2e2;
    color: #b91c1c;
}

.mie-status-badge.not-run {
    background: #f1f5f9;
    color: #64748b;
}

/* ── Quick Actions Bar ──────────────────────────────────────── */
.quick-actions {
    padding: 14px 18px;
    background: #f8fafc;
    border-top: 1px solid var(--app-line, #e2e8f0);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Main Actions Footer ────────────────────────────────────── */
.actions-bar {
    background: var(--app-panel-bg, #fff);
    border: 1px solid var(--app-line, #e2e8f0);
    border-radius: var(--app-radius, 12px);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    box-shadow: 0 2px 10px rgba(31,41,55,0.06);
}

.actions-bar .spacer {
    flex: 1;
}

#mieStatus {
    font-size: 12.5px;
    color: var(--app-muted, #6b7280);
    font-style: italic;
    padding: 0 6px;
}

#mieStatus.ok  { color: var(--app-ok, #15803d);  font-style: normal; font-weight: 600; }
#mieStatus.err { color: var(--app-bad, #b91c1c);  font-style: normal; font-weight: 600; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s, box-shadow 0.18s, transform 0.1s;
    text-decoration: none;
    line-height: 1;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--app-button-bg, #2A54B1);
    color: var(--app-button-text, #fff);
    box-shadow: 0 2px 8px rgba(42,84,177,0.25);
}
.btn-primary:hover { background: var(--app-button-bg-alt, #1e3f85); }

.btn-success {
    background: #16a34a;
    color: #fff;
    box-shadow: 0 2px 8px rgba(22,163,74,0.25);
}
.btn-success:hover { background: #15803d; }

.btn-info {
    background: #0891b2;
    color: #fff;
    box-shadow: 0 2px 8px rgba(8,145,178,0.25);
}
.btn-info:hover { background: #0e7490; }

.btn-secondary {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}
.btn-secondary:hover { background: #e2e8f0; border-color: #94a3b8; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Print styles ───────────────────────────────────────────── */
@media print {
    .app-hero-bar,
    .phase-card,
    .quick-actions,
    .actions-bar { display: none !important; }

    .mie-container { margin: 0; padding: 0; max-width: 100%; }

    .checks-card,
    .invoice-meta,
    .meta-block { box-shadow: none; border-radius: 0; }

    .mie-table thead th { background: #f0f0f0 !important; color: #000 !important; }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 720px) {
    .invoice-meta { grid-template-columns: 1fr; }
    .phase-card   { flex-direction: column; }
    .actions-bar  { flex-direction: column; align-items: stretch; }
    .actions-bar .spacer { display: none; }
    .actions-bar .btn { justify-content: center; }
    .quick-actions { flex-direction: column; }
    .quick-actions .btn { width: 100%; justify-content: center; }
}
