/* ============================================================
   Variables
   ============================================================ */

:root {
  --primary:       #F0C000;
  --primary-dark:  #FFCD00;
  --primary-light: #FFFBDB;
  --success:       #16a34a;
  --success-light: #f0fdf4;
  --error:         #dc2626;
  --error-light:   #fef2f2;
  --text:          #111827;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --bg:            #f1f5f9;
  --card:          #ffffff;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,0.08);
}

/* ============================================================
   Reset & Base
   ============================================================ */

[v-cloak] { display: none !important; }

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ============================================================
   Layout
   ============================================================ */

.page-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  background: #1a1a1a;
  color: #fff;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.main-content {
  flex: 1;
  padding: 1.5rem 1rem 3rem;
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   Logo & header brand
   ============================================================ */

.header-logo-badge {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-logo {
  height: 46px;
  width: auto;
  display: block;
}

.header-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.header-brand-org {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--primary);
}

.header-brand-app {
  font-size: 1.55rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}

.header-brand-sub {
  font-size: 0.82rem;
  color: #9ca3af;
  margin-top: 0.15rem;
}

.login-logo {
  display: block;
  height: 72px;
  width: auto;
  margin: 0 auto 1rem;
}

/* ============================================================
   Card
   ============================================================ */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ============================================================
   Intro text
   ============================================================ */

.intro-box {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: #7a5200;
  line-height: 1.6;
}
.intro-box a {
  color: #4a3200;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.intro-box a:hover {
  color: #1a1a1a;
}

/* ============================================================
   Form
   ============================================================ */

.form-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.form-section-title:first-child { margin-top: 0; }

.field {
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.field label .req {
  color: var(--error);
  margin-left: 0.2rem;
}

.field label .opt {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.78rem;
  margin-left: 0.35rem;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,205,0,0.4);
}

input[type="text"].invalid,
input[type="password"].invalid,
select.invalid,
textarea.invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.2rem;
}

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

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.field-error {
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 0.3rem;
}

/* custom room input that slides in */
.custom-room-wrap {
  margin-top: 0.5rem;
}

/* ============================================================
   Submit button
   ============================================================ */

.btn-submit {
  display: block;
  width: 100%;
  padding: 0.8rem;
  background: var(--primary);
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 1.5rem;
}

.btn-submit:hover  { background: var(--primary-dark); }
.btn-submit:active { transform: scale(0.99); }
.btn-submit:disabled {
  background: #FFE87C;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   Success state
   ============================================================ */

.success-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: var(--success-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.success-icon svg { color: var(--success); }

.success-card h2 {
  font-size: 1.3rem;
  color: var(--success);
  margin-bottom: 0.5rem;
}

.success-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.btn-new {
  display: inline-block;
  padding: 0.65rem 1.5rem;
  background: var(--primary);
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-new:hover { background: var(--primary-dark); }

/* ============================================================
   Loading / error states
   ============================================================ */

.loading-msg, .load-error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.load-error { color: var(--error); }

/* ============================================================
   Login page
   ============================================================ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.login-card .login-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.login-error {
  background: var(--error-light);
  color: var(--error);
  border-radius: 6px;
  padding: 0.65rem 0.9rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   Admin header
   ============================================================ */

.admin-header {
  justify-content: space-between;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-user {
  font-size: 0.82rem;
  color: #9ca3af;
}

.btn-logout {
  background: var(--primary);
  color: #1a1a1a;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-logout:hover { background: var(--primary-dark); }

/* ============================================================
   Admin content
   ============================================================ */

.admin-content {
  max-width: 860px;
}

/* ============================================================
   Toolbar
   ============================================================ */

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.filter-tab {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.filter-tab:hover { border-color: var(--primary); color: #7a5200; }

.filter-tab.active {
  background: var(--primary-light);
  border-color: #e9d44a;
  border-bottom: 2px solid var(--primary);
  color: var(--text);
  font-weight: 600;
}

.tab-count {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
  padding: 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.filter-tab.active .tab-count {
  background: var(--primary);
  color: #1a1a1a;
}

.btn-new-ticket {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  background: var(--primary);
  color: #1a1a1a;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-new-ticket:hover { background: var(--primary-dark); }

.sort-select {
  padding: 0.4rem 2rem 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  appearance: none;
  cursor: pointer;
}

/* ============================================================
   Empty / loading
   ============================================================ */

.empty-msg {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ============================================================
   Ticket cards
   ============================================================ */

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.ticket-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.ticket-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

/* Priority-based left border */
.ticket-card.priority-border-low      { border-left-color: #3b82f6; }
.ticket-card.priority-border-medium   { border-left-color: var(--primary); }
.ticket-card.priority-border-high     { border-left-color: #f97316; }
.ticket-card.priority-border-critical { border-left-color: #ef4444; }
.ticket-card.priority-border-none     { border-left-color: var(--border); }

.ticket-card-header {
  padding: 0.9rem 1rem;
  cursor: pointer;
  position: relative;
  user-select: none;
}

.ticket-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.ticket-id {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.ticket-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
  padding-right: 1.5rem;
}

.ticket-summary-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.ticket-reporter { font-weight: 600; }
.ticket-dot { color: var(--text-muted); }
.ticket-location, .ticket-hw { color: var(--text-muted); }

.ticket-preview {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.45;
}

.ticket-expand-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* ============================================================
   Status & priority badges
   ============================================================ */

.status-badge, .priority-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-badge.status-open        { background: #dbeafe; color: #1d4ed8; }
.status-badge.status-in_progress { background: #fef3c7; color: #b45309; }
.status-badge.status-done        { background: #dcfce7; color: #15803d; }

.priority-badge.priority-low      { background: #f3f4f6; color: #6b7280; }
.priority-badge.priority-medium   { background: #FFF0A0; color: #7a5200; }
.priority-badge.priority-high     { background: #ffedd5; color: #c2410c; }
.priority-badge.priority-critical { background: #fee2e2; color: #b91c1c; }

/* ============================================================
   Ticket detail (expanded)
   ============================================================ */

.ticket-detail {
  border-top: 1px solid var(--border);
  padding: 1rem;
  background: #fafbfc;
}

.detail-section {
  margin-bottom: 0.85rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.detail-text {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}

.detail-controls {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.control-group-full { flex: 1 1 100%; }

.control-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.control-select {
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  background: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  appearance: none;
  min-width: 140px;
}

.control-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,205,0,0.4);
}

.control-textarea {
  width: 100%;
  min-height: 70px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: inherit;
  resize: vertical;
  background: #fff;
}

.control-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,205,0,0.4);
}

.control-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1 1 100%;
  justify-content: flex-end;
}

.btn-save {
  background: var(--primary);
  color: #1a1a1a;
  border: none;
  border-radius: 7px;
  padding: 0.5rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-save:hover    { background: var(--primary-dark); }
.btn-save:disabled { background: #FFE87C; cursor: not-allowed; }

.save-msg  { font-size: 0.85rem; }
.save-ok   { color: var(--success); }
.save-error{ color: var(--error); }

/* ============================================================
   Responsive — desktop
   ============================================================ */

@media (min-width: 600px) {
  .site-header { padding: 1.1rem 2rem; }
  .site-header h1 { font-size: 1.35rem; }
  .main-content { padding: 2rem 1.5rem 4rem; }
  .card { padding: 2rem; }

  .fields-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0 1rem;
  }
}

@media (min-width: 900px) {
  .main-content { padding: 2.5rem 1rem 4rem; }
}

/* ============================================================
   Settings toggle button
   ============================================================ */

.btn-settings-toggle {
  text-decoration: none;
  background: transparent;
  color: #9ca3af;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-settings-toggle:hover { border-color: var(--primary); color: var(--primary); }

.btn-settings-toggle.active {
  background: var(--primary);
  color: #1a1a1a;
  border-color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   Settings panel
   ============================================================ */

.settings-wrap {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.settings-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem;
}

.settings-card-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.settings-section-sub {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 1rem 0 0.6rem;
}

.settings-intro-textarea {
  min-height: 100px;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ============================================================
   Item list (rooms / hardware types)
   ============================================================ */

.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.item-order-btns {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.btn-order {
  background: none;
  border: none;
  padding: 0 0.2rem;
  font-size: 0.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.1s;
}

.btn-order:hover:not(:disabled) { color: var(--text); }
.btn-order:disabled { opacity: 0.25; cursor: default; }

.item-name {
  flex: 1;
  font-size: 0.88rem;
}

.btn-item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.btn-item-delete:hover {
  background: var(--error-light);
  color: var(--error);
}

.item-add-row {
  display: flex;
  gap: 0.5rem;
}

.item-add-row input {
  flex: 1;
}

.btn-add {
  background: var(--primary);
  color: #1a1a1a;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-add:hover { background: var(--primary-dark); }

/* ============================================================
   Toggle switch
   ============================================================ */

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 12px;
  transition: background 0.2s;
}

.toggle-switch input:checked + .toggle-track { background: var(--primary); }

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb { left: 21px; }
