/* ============================================================
   Manthragiri QC Report PWA — Design System
   Green gradient theme, mobile-first (field staff use on phones)
   ============================================================ */

:root {
    --green-1: #0f9d58;
    --green-2: #0cbb53;
    --green-3: #34d17f;
    --green-dark: #0a6e3e;
    --gradient-primary: linear-gradient(135deg, #0a6e3e 0%, #0f9d58 45%, #34d17f 100%);
    --gradient-primary-hover: linear-gradient(135deg, #085c33 0%, #0c8449 45%, #29b56c 100%);
    --gradient-danger: linear-gradient(135deg, #a30f0f 0%, #d93636 100%);
    --bg-page: #f4f8f6;
    --card-bg: #ffffff;
    --text-main: #1e2b24;
    --text-muted: #6b7c74;
    --border-light: #e1ece5;
    --radius: 14px;
    --shadow-card: 0 2px 10px rgba(15, 60, 40, 0.08);
    --shadow-btn: 0 4px 14px rgba(15, 157, 88, 0.35);
    font-size: 16px;
}

* { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }

html, body {
    overscroll-behavior-y: contain; /* stop iOS/Android rubber-band bounce feeling un-app-like */
}

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    padding-bottom: 78px; /* room for bottom nav */
}

a { text-decoration: none; color: inherit; }

/* ---------------- Header ---------------- */
.app-header {
    background: var(--gradient-primary);
    color: #fff;
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top)); /* clear the notch/status bar in standalone mode */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-header-left { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1.05rem; }
.app-logo { font-size: 1.3rem; }
.app-header-right { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.staff-name { opacity: 0.95; }
.icon-btn {
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}

/* ---------------- Main content ---------------- */
.app-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ---------------- Cards ---------------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 18px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
}
.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--green-dark);
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------------- Forms ---------------- */
label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 12px 0 6px;
}
input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--border-light);
    font-size: 1rem;
    background: #fbfdfc;
    color: var(--text-main);
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--green-2);
    background: #fff;
}
textarea { min-height: 90px; resize: vertical; }

/* ---------------- Buttons: green gradient ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    color: #fff;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-btn);
    transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.2s;
}
.btn:hover { background: var(--gradient-primary-hover); }
.btn:active { transform: scale(0.98); box-shadow: 0 2px 6px rgba(15,157,88,0.3); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-sm { padding: 9px 14px; font-size: 0.85rem; width: auto; border-radius: 9px; }
.btn-outline {
    background: #fff;
    color: var(--green-dark);
    border: 1.5px solid var(--green-2);
    box-shadow: none;
}
.btn-danger { background: var(--gradient-danger); box-shadow: 0 4px 14px rgba(163,15,15,0.3); }
.btn-block { display: flex; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* ---------------- Bottom nav ---------------- */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    z-index: 50;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    gap: 2px;
    padding: 4px 10px;
    border-radius: 10px;
}
.nav-icon { font-size: 1.25rem; }
.nav-item.active, .nav-item:active { color: var(--green-dark); background: #eafaf1; }

/* ---------------- Status chips ---------------- */
.chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.chip-green { background: #e3f9ee; color: var(--green-dark); }
.chip-orange { background: #fff2df; color: #a35d0a; }
.chip-red { background: #fde7e7; color: #a30f0f; }
.chip-gray { background: #eef1ef; color: var(--text-muted); }

/* ---------------- Loom table (dynamic rows) ---------------- */
.loom-table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border-light); }
table.loom-table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: 0.85rem; }
table.loom-table th {
    background: var(--gradient-primary);
    color: #fff;
    padding: 8px 6px;
    position: sticky; top: 0;
}
table.loom-table td { padding: 6px; border-bottom: 1px solid var(--border-light); }
table.loom-table td input { padding: 7px 6px; font-size: 0.85rem; text-align: center; }
table.loom-table tr:nth-child(even) { background: #fafcfb; }

/* ---------------- Defect checklist ---------------- */
.defect-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-light);
}
.defect-row:last-child { border-bottom: none; }
.defect-row input[type="checkbox"] { width: 20px; height: 20px; margin-top: 4px; accent-color: var(--green-2); flex-shrink: 0; }
.defect-info { flex: 1; }
.defect-name-ta { font-weight: 600; font-size: 0.95rem; }
.defect-name-en { font-size: 0.75rem; color: var(--text-muted); }
.defect-looms-input { margin-top: 6px; display: none; }
.defect-row.checked .defect-looms-input { display: block; }

/* ---------------- Dashboard stat cards ---------------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card {
    background: var(--gradient-primary);
    color: #fff;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-btn);
}
.stat-number { font-size: 1.6rem; font-weight: 800; }
.stat-label { font-size: 0.78rem; opacity: 0.9; }

/* ---------------- Signature pad ---------------- */
.sig-pad-wrap { border: 1.5px dashed var(--border-light); border-radius: 10px; background: #fbfdfc; }
canvas.sig-pad {
    width: 100%; height: 140px; touch-action: none; display: block;
    -webkit-touch-callout: none; /* stop iOS's "save image" long-press menu interrupting a signature */
    -webkit-user-select: none;
    user-select: none;
}

/* ---------------- Offline banner ---------------- */
.offline-banner {
    background: #fff2df;
    color: #a35d0a;
    text-align: center;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    position: sticky; top: 0; z-index: 60;
}
.hidden { display: none !important; }

/* ---------------- Install banner ---------------- */
.install-banner {
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    background: var(--gradient-primary);
    color: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-btn);
    z-index: 200;
    animation: install-banner-in 0.25s ease-out;
}
@keyframes install-banner-in {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.install-banner-icon { font-size: 1.3rem; flex-shrink: 0; }
.install-banner-text { flex: 1; font-size: 0.85rem; line-height: 1.3; }
.install-banner-btn {
    background: #fff;
    color: var(--green-dark);
    border: none;
    padding: 8px 14px;
    border-radius: 9px;
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
    cursor: pointer;
}
.install-banner-close {
    background: transparent;
    border: none;
    color: #fff;
    opacity: 0.85;
    font-size: 1rem;
    padding: 4px;
    flex-shrink: 0;
    cursor: pointer;
}

/* ---------------- Misc ---------------- */
.center { text-align: center; }
.muted { color: var(--text-muted); font-size: 0.85rem; }
.section-divider { height: 1px; background: var(--border-light); margin: 18px 0; }
.logo-badge {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--gradient-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: #fff; margin: 0 auto 14px;
    box-shadow: var(--shadow-btn);
}
.field-error { color: #a30f0f; font-size: 0.8rem; margin-top: 4px; }
.toast {
    position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
    background: var(--text-main); color: #fff; padding: 10px 18px;
    border-radius: 30px; font-size: 0.85rem; z-index: 100; opacity: 0;
    transition: opacity 0.3s;
}
.toast.show { opacity: 1; }
