/* Grip op IT Helpdesk — brand-matched UI */
:root {
  --green: #a4c422;
  --green-dark: #8bab18;
  --green-soft: #eef5d4;
  --navy: #2c3a64;
  --navy-dark: #222d4e;
  --ink: #333a40;
  --muted: #6b7580;
  --line: #e4e8ec;
  --bg: #f4f6f8;
  --white: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 1px 2px rgba(20, 30, 50, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

  --pri-urgent: #e2483d;
  --pri-high: #f08a24;
  --pri-normal: #4a90d9;
  --pri-low: #9aa4ad;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--navy); }
button { font-family: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
  text-align: center;
}
.login-card img.logo { max-width: 190px; margin: 4px auto 18px; display: block; }
.login-card h1 { font-size: 18px; color: var(--navy); margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-card form { text-align: left; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 14px; font-weight: 600; color: var(--navy); font-size: 13px; }
label.field span { display: block; margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--white);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(164, 196, 34, .2);
}
textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; border-radius: 8px; padding: 9px 16px;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--green); color: #1f2a12; }
.btn-primary:hover { background: var(--green-dark); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-dark); }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.error-msg { color: var(--pri-urgent); font-size: 13px; margin: 10px 0 0; min-height: 18px; }

/* ---------- App shell ---------- */
.app { display: none; grid-template-rows: 56px 1fr; height: 100vh; }
.app.active { display: grid; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white); border-bottom: 1px solid var(--line);
  padding: 0 18px; box-shadow: var(--shadow); z-index: 5;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .brand img { height: 30px; }
.topbar .brand .title { font-weight: 700; color: var(--navy); font-size: 15px; letter-spacing: .2px; }
.topbar .brand .title small { display:block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: .3px; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.topbar .user { text-align: right; font-size: 13px; line-height: 1.2; }
.topbar .user b { color: var(--navy); }
.topbar .user small { color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green); color: #1f2a12; font-weight: 700;
  display: grid; place-items: center; font-size: 14px;
}

.layout { display: grid; grid-template-columns: 232px 1fr; overflow: hidden; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--navy); color: #c9d0e4; overflow-y: auto; padding: 14px 0;
}
.sidebar .nav-group { padding: 6px 14px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .6px; color: #7c88ad; margin-top: 8px; }
.sidebar .nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px; cursor: pointer; font-size: 13.5px; color: #d6dcec;
  border-left: 3px solid transparent;
}
.sidebar .nav-item:hover { background: rgba(255,255,255,.05); }
.sidebar .nav-item.active { background: rgba(164,196,34,.14); border-left-color: var(--green); color: #fff; font-weight: 600; }
.sidebar .nav-item .count {
  background: rgba(255,255,255,.14); border-radius: 20px; padding: 1px 8px;
  font-size: 11px; min-width: 22px; text-align: center;
}
.sidebar .nav-item.active .count { background: var(--green); color: #1f2a12; }

/* ---------- Main ---------- */
.main { overflow-y: auto; padding: 18px 22px; }
.main-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.main-head h2 { margin: 0; color: var(--navy); font-size: 19px; }
.main-head .tools { display: flex; gap: 8px; align-items: center; }
.search-box { position: relative; }
.search-box input { padding-left: 12px; width: 230px; }

/* ---------- Ticket list ---------- */
.ticket-list { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.ticket-row {
  display: grid; grid-template-columns: 6px 1fr 130px 120px 140px; gap: 12px;
  align-items: center; padding: 12px 16px 12px 10px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background .1s;
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: #fafbfc; }
.pri-bar { width: 4px; height: 38px; border-radius: 3px; }
.pri-urgent { background: var(--pri-urgent); }
.pri-high { background: var(--pri-high); }
.pri-normal { background: var(--pri-normal); }
.pri-low { background: var(--pri-low); }
.ticket-main .subj { font-weight: 600; color: var(--navy); }
.ticket-main .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ticket-col { font-size: 12.5px; color: var(--muted); }
.ticket-col .who { color: var(--ink); font-weight: 500; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.st-new { background: #e6effb; color: #2c66b0; }
.st-open { background: var(--green-soft); color: #5f7714; }
.st-pending { background: #fdf1dd; color: #b5730f; }
.st-on_hold { background: #f0e9f7; color: #7a4ea8; }
.st-solved { background: #e2f3e6; color: #2f8a44; }
.st-closed { background: #eceff1; color: #6b7580; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }

/* ---------- Ticket detail ---------- */
.detail { display: grid; grid-template-columns: 1fr 300px; gap: 18px; }
.thread-panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.thread-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.thread-head h2 { margin: 0 0 6px; color: var(--navy); font-size: 18px; }
.thread-head .sub { color: var(--muted); font-size: 12.5px; }
.thread { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; max-height: none; }
.msg { display: flex; gap: 11px; }
.msg .bubble { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; background: #fff; }
.msg.customer .bubble { background: #fbfcf5; border-color: #e8eecb; }
.msg.system { justify-content: center; }
.msg.system .sys-note { font-size: 12px; color: var(--muted); font-style: italic; background: var(--bg); padding: 4px 12px; border-radius: 20px; }
.msg .who { font-weight: 600; color: var(--navy); font-size: 13px; }
.msg .when { color: var(--muted); font-size: 11.5px; }
.msg .body { margin-top: 5px; white-space: pre-wrap; }
.msg .internal-tag { font-size: 10.5px; background: #fdf1dd; color: #b5730f; padding: 1px 7px; border-radius: 4px; margin-left: 6px; }
.msg.internal .bubble { background: #fffbf2; border-color: #f5e2bf; }

.reply-box { border-top: 1px solid var(--line); padding: 14px 20px; background: #fafbfc; }
.reply-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.reply-tab { padding: 5px 12px; border-radius: 7px 7px 0 0; font-size: 12.5px; cursor: pointer; color: var(--muted); font-weight: 600; }
.reply-tab.active { color: var(--navy); background: var(--white); border: 1px solid var(--line); border-bottom: none; }
.reply-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

/* properties panel */
.props { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; height: fit-content; }
.props h3 { margin: 0 0 12px; color: var(--navy); font-size: 14px; }
.props label.field { margin-bottom: 12px; }
.props .req-info { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; font-size: 12.5px; }
.props .req-info .r { margin-bottom: 4px; }
.props .req-info .r span { color: var(--muted); }

/* ---------- Tables (admin) ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.card .card-head { padding: 13px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.card .card-head h3 { margin: 0; color: var(--navy); font-size: 15px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
.chip { display:inline-block; padding: 1px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 600; background: var(--green-soft); color: #5f7714; }
.chip.admin { background: #e6effb; color: #2c66b0; }
.chip.inactive { background: #eceff1; color: #6b7580; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,28,45,.5); display: none; place-items: center; z-index: 20; padding: 20px; }
.modal-backdrop.active { display: grid; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 460px; box-shadow: 0 20px 50px rgba(0,0,0,.3); max-height: 90vh; overflow-y: auto; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; color: var(--navy); }
.modal-head .x { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; background: none; border: none; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .detail { grid-template-columns: 1fr; }
  .ticket-row { grid-template-columns: 6px 1fr 100px; }
  .ticket-row .hide-sm { display: none; }
}
