/* ============================================================
   NUR AGC — Smart Project Management
   app.css — Unified Design System
   ============================================================ */

/* ---- Variables ---- */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  --primary: #042c42;
  --primary-hover: #031e2e;
  --primary-light: #e8edf2;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-border: #bbf7d0;

  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-border: #fecaca;

  --info: #0369a1;
  --info-bg: #e0f2fe;
  --info-border: #bae6fd;

  --pending: #7c3aed;
  --pending-bg: #ede9fe;
  --pending-border: #ddd6fe;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  padding: 4px 10px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.brand .title { font-weight: 700; font-size: 14px; letter-spacing: .2px; }
.brand .subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  transition: background .15s;
}
.nav a:hover { background: #f1f5f9; }
.nav a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav .hint { color: var(--muted); font-size: 12px; }

.nav-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.nav-footer .user-name { font-weight: 700; font-size: 13px; }
.nav-footer .user-role { color: var(--muted); font-size: 12px; }

/* ---- Content ---- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.header .page-title { font-size: 16px; font-weight: 700; margin: 0; }
.header .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.main { padding: 20px; }

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.card-subtitle { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* ============================================================
   GRID
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}
.col-12 { grid-column: span 12; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.table th {
  padding: 10px 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
  color: var(--text);
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table .muted { color: var(--muted); text-align: center; }

/* ============================================================
   BADGE
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #fff;
}
/* Status variants */
.badge.active,
.badge.success    { background: var(--success-bg);  color: var(--success);  border-color: var(--success-border); }
.badge.planning,
.badge.info       { background: var(--info-bg);     color: var(--info);     border-color: var(--info-border); }
.badge.warning,
.badge.on-hold    { background: var(--warning-bg);  color: var(--warning);  border-color: var(--warning-border); }
.badge.danger,
.badge.closed     { background: var(--danger-bg);   color: var(--danger);   border-color: var(--danger-border); }
.badge.pending    { background: var(--pending-bg);  color: var(--pending);  border-color: var(--pending-border); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: background .15s, border-color .15s;
  text-decoration: none;
  line-height: 1;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }

.btn.primary, .btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn.primary:hover, .btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn.danger, .btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn.sm, .btn-sm { padding: 5px 10px; font-size: 12px; }

/* ============================================================
   ACTIONS ROW
   ============================================================ */
.actions, .inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.actions { justify-content: flex-end; }

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* ============================================================
   FORMS (Global)
   ============================================================ */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea,
.select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus,
select:focus,
textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,81,82,.12);
}
textarea { resize: vertical; min-height: 88px; }

/* ============================================================
   FORM SECTION HEADER
   ============================================================ */
.form-section {
  margin-top: 8px;
}
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   DAILY REPORTS — Repeat Rows
   ============================================================ */
.repeat-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}
.repeat-row-4 {
  display: grid;
  grid-template-columns: 1.6fr 1.4fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}
.repeat-row input,
.repeat-row-4 input { width: 100%; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}
.alert.error  { border-color: var(--danger-border);  background: var(--danger-bg);  color: #7a1520; }
.alert.success{ border-color: var(--success-border); background: var(--success-bg); color: #14532d; }
.alert.info   { border-color: var(--info-border);    background: var(--info-bg);    color: #075985; }

/* ============================================================
   KV ROWS (Detail/Show pages)
   ============================================================ */
.kv-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-label { color: var(--muted); font-size: 13px; min-width: 140px; }
.kv-value { font-size: 14px; color: var(--text); }

.text-block {
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login-card { width: 100%; max-width: 400px; }
.login-head { margin-bottom: 20px; }
.login-head .title   { font-size: 20px; font-weight: 800; }
.login-head .subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---- Icon action buttons (tables) ---- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background 150ms;
  flex-shrink: 0;
  text-decoration: none;
}
.btn-icon.view   { background: #e6f4f5; color: #01696f; }
.btn-icon.view:hover { background: #cedcd8; }
.btn-icon.edit   { background: #fef3e2; color: #b45309; }
.btn-icon.edit:hover { background: #fde8c0; }
.btn-icon.danger { background: #fde8ef; color: #a12c7b; }
.btn-icon.danger:hover { background: #f8ccdc; }

/* ---- Page action buttons (show pages: back / edit / delete) ---- */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms, color 150ms;
}
.btn-action.back   { background: #f3f4f6; color: #374151; }
.btn-action.back:hover { background: #e5e7eb; }
.btn-action.edit   { background: #fef3e2; color: #b45309; border: 1px solid #fde8c0; }
.btn-action.edit:hover { background: #fde8c0; }
.btn-action.danger { background: #fde8ef; color: #a12c7b; border: 1px solid #f8ccdc; }
.btn-action.danger:hover { background: #f8ccdc; }

/* ---- Stage / daily report file upload label ---- */
.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #f0faf9;
  color: #0f766e;
  border: 1px dashed #99d6d0;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 150ms;
  margin-top: 8px;
}
.btn-upload:hover { background: #ccefec; }
.btn-upload input[type="file"] {
  display: none;
}
.upload-filenames {
  font-size: 12px;
  color: #6b7280;
  margin-left: 8px;
}

.daily-reports-form textarea {
  min-height: 60px;
  resize: vertical;
}

.btn-add-row {
  margin-top: 8px;
}

.stage-progress-row .btn-icon {
  margin-bottom: 4px;
}

.stage-seq-warning {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  line-height: 1.4;
}

.stage-status-select {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
}
.stage-pending { background:#f3f4f6; color:#6b7280; }
.stage-in_progress { background:#dbeafe; color:#1e40af; }
.stage-done { background:#d4efcc; color:#1e3f0a; }
.stage-not_done { background:#fde8ef; color:#a12c7b; }
.stage-hold { background:#fef3e2; color:#b45309; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .col-6   { grid-column: span 12; }
}

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .repeat-row, .repeat-row-4 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
}

/* ---- Toolbar: lone button floats right ---- */
.toolbar > .btn:only-child,
.toolbar > a:only-child {
  margin-left: auto;
}
