/* ============================================================
   ESM Platform — Cream & Teal Theme + Bai Jamjuree Font
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bai+Jamjuree:wght@300;400;500;600;700;800&display=swap');

:root {
  /* ---- Cream / Teal Palette ---- */
  --bg-base:    #f0ede6;
  --bg-main:    #ece8e0;
  --bg-card:    #f8f5ee;
  --bg-card2:   #edeae2;
  --bg-hover:   rgba(32,178,170,0.06);
  --border:     rgba(32,178,170,0.18);
  --border-hover: rgba(32,178,170,0.5);

  /* Teal / Sea-green primary */
  --primary:      #1a9e97;
  --primary-dark: #137a74;
  --primary-glow: rgba(26,158,151,0.22);
  --secondary:    #2bbfb8;

  --success:    #2e9e6e;
  --warning:    #d4850a;
  --danger:     #c94040;
  --info:       #1a9eb8;

  --text-dark:      #1c3b38;
  --text-body:      #2d5550;
  --text-muted:     #7a9e9b;
  --text-secondary: #4a7572;

  --sidebar-w:  240px;
  --radius:     10px;
  --radius-lg:  14px;
  --shadow:     0 4px 20px rgba(26,158,151,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg-main);
  color: var(--text-body);
  font-family: 'Bai Jamjuree', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: rgba(26,158,151,0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---- APP LAYOUT ---- */
.app-wrapper { display: flex; min-height: 100vh; }
.main-content { flex: 1; margin-left: var(--sidebar-w); padding: 28px 32px; max-width: calc(100vw - var(--sidebar-w)); overflow-x: hidden; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card2);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  box-shadow: 2px 0 12px rgba(26,158,151,0.08);
}
.sidebar-header { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, var(--primary-dark), var(--primary)); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; color: #fff; }
.sidebar-logo i { font-size: 20px; color: rgba(255,255,255,0.9); }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
  color: var(--text-secondary); text-decoration: none;
  font-size: 14px; font-weight: 600; transition: all 0.2s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--primary-dark); }
.nav-item.active { background: linear-gradient(135deg, rgba(26,158,151,0.15), rgba(19,122,116,0.08)); color: var(--primary-dark); border-left: 3px solid var(--primary); font-weight: 700; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.nav-item-portal { margin-top: auto; border-top: 1px solid var(--border); border-radius: 0; padding-top: 14px; color: var(--text-muted); font-size: 13px; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; background: var(--bg-main); }
.user-avatar { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; background: var(--primary); }
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 700; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout { color: var(--text-muted); text-decoration: none; padding: 6px; border-radius: 6px; transition: 0.2s; }
.btn-logout:hover { color: var(--danger); }
.lang-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 26px; border-radius: 6px; background: rgba(26,158,151,0.12); color: var(--primary-dark); font-size: 11px; font-weight: 800; text-decoration: none; transition: 0.2s; border: 1px solid rgba(26,158,151,0.2); letter-spacing: 0.3px; }
.lang-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- PAGE HEADER ---- */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; color: var(--text-dark); display: flex; align-items: center; gap: 10px; }
.page-title i { color: var(--primary); }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); text-decoration: none; font-size: 13px; margin-bottom: 8px; transition: 0.2s; }
.back-link:hover { color: var(--primary); }

/* ---- CARDS ---- */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 2px 8px rgba(26,158,151,0.06); }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); background: rgba(26,158,151,0.04); }
.card-title { font-size: 15px; font-weight: 700; color: var(--text-dark); display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }
.card-body { padding: 20px; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 10px; font-size: 14px; font-weight: 700;
  border: none; cursor: pointer; font-family: 'Bai Jamjuree', sans-serif; text-decoration: none;
  transition: all 0.2s; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 3px 10px var(--primary-glow); }
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 6px 16px var(--primary-glow); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-hover); }
.btn-danger { background: rgba(201,64,64,0.1); color: var(--danger); border: 1px solid rgba(201,64,64,0.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%; background: #fff; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 10px 14px; color: var(--text-dark);
  font-family: 'Bai Jamjuree', sans-serif; font-size: 14px; outline: none; transition: all 0.2s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-control::placeholder { color: rgba(122,158,155,0.6); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; background: #fff; }
input[type="color"].form-control { padding: 4px; height: 40px; cursor: pointer; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; align-items: center; }
.form-check label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--text-secondary); }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.input-password { position: relative; }
.input-password .form-control { padding-right: 44px; }
.pwd-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }

/* ---- ALERTS / FLASH ---- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.alert-error  { background: rgba(201,64,64,0.08);  border: 1px solid rgba(201,64,64,0.3);  color: #a33030; }
.alert-success{ background: rgba(46,158,110,0.1); border: 1px solid rgba(46,158,110,0.3); color: #1f7a52; }
.flash { padding: 12px 20px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 10px; animation: slideDown 0.3s ease; }
.flash-success{ background: rgba(46,158,110,0.1); border: 1px solid rgba(46,158,110,0.3); color: #1f7a52; }
.flash-error  { background: rgba(201,64,64,0.08);  border: 1px solid rgba(201,64,64,0.3);  color: #a33030; }
@keyframes slideDown { from { opacity:0; transform: translateY(-10px); } to { opacity:1; transform: translateY(0); } }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 50px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.badge-lg { padding: 5px 14px; font-size: 12px; }

/* Status — teal tones */
.status-new       { background: rgba(26,158,151,0.12); color: #137a74; border: 1px solid rgba(26,158,151,0.2); }
.status-open      { background: rgba(26,158,184,0.12); color: #1478a0; border: 1px solid rgba(26,158,184,0.2); }
.status-progress  { background: rgba(212,133,10,0.12); color: #a36308; border: 1px solid rgba(212,133,10,0.2); }
.status-pending   { background: rgba(130,100,180,0.12); color: #6240b0; border: 1px solid rgba(130,100,180,0.2); }
.status-resolved  { background: rgba(46,158,110,0.12); color: #1f7a52; border: 1px solid rgba(46,158,110,0.2); }
.status-closed    { background: rgba(122,158,155,0.12); color: #5a8a87; border: 1px solid rgba(122,158,155,0.2); }

/* Priority */
.priority-low      { background: rgba(46,158,110,0.1);  color: #1f7a52; border: 1px solid rgba(46,158,110,0.2); }
.priority-medium   { background: rgba(212,133,10,0.1);  color: #a36308; border: 1px solid rgba(212,133,10,0.2); }
.priority-high     { background: rgba(201,64,64,0.1);   color: #a33030; border: 1px solid rgba(201,64,64,0.2); }
.priority-critical { background: rgba(160,30,30,0.12);  color: #8b1a1a; border: 1.5px solid rgba(160,30,30,0.4); }

/* Role */
.badge-role-admin   { background: rgba(201,64,64,0.1);   color: #a33030; }
.badge-role-manager { background: rgba(212,133,10,0.1);  color: #a36308; }
.badge-role-agent   { background: rgba(26,158,151,0.1);  color: #137a74; }

/* SLA */
.badge-warning { background: rgba(212,133,10,0.12); color: #a36308; }
.badge-breach  { background: rgba(201,64,64,0.12);  color: #a33030; }

/* ---- FILTER BAR ---- */
.filter-bar { margin-bottom: 20px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-search { flex: 1; min-width: 200px; max-width: 300px; }
.filter-select { width: auto; min-width: 140px; }
.filter-label { font-size: 13px; color: var(--text-muted); white-space: nowrap; font-weight: 600; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { padding: 11px 16px; text-align: left; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; background: rgba(26,158,151,0.04); }
.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; color: var(--text-body); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-hover); }
.ticket-row { transition: background 0.15s; }
.row-breach td { background: rgba(201,64,64,0.04); }
.row-warning td { background: rgba(212,133,10,0.04); }

/* ---- KPI GRID ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 18px; position: relative; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 2px 8px rgba(26,158,151,0.06); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(26,158,151,0.12); }
.kpi-card::before { content:''; position:absolute; top:-20px; right:-20px; width:80px; height:80px; border-radius: 50%; opacity: 0.1; }
.kpi-total::before   { background: var(--primary); }
.kpi-new::before     { background: var(--info); }
.kpi-open::before    { background: var(--warning); }
.kpi-pending::before { background: #8264b4; }
.kpi-resolved::before{ background: var(--success); }
.kpi-breach::before  { background: var(--danger); }
.kpi-ok::before      { background: var(--success); }
.kpi-icon { font-size: 22px; margin-bottom: 10px; }
.kpi-total .kpi-icon   { color: var(--primary); }
.kpi-new .kpi-icon     { color: var(--info); }
.kpi-open .kpi-icon    { color: var(--warning); }
.kpi-pending .kpi-icon { color: #8264b4; }
.kpi-resolved .kpi-icon{ color: var(--success); }
.kpi-breach .kpi-icon  { color: var(--danger); }
.kpi-ok .kpi-icon      { color: var(--success); }
.kpi-value { font-size: 30px; font-weight: 800; color: var(--text-dark); line-height: 1; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }
.kpi-badge { font-size: 11px; padding: 2px 8px; border-radius: 50px; margin-top: 6px; display: inline-block; }
.kpi-badge-warn { background: rgba(212,133,10,0.15); color: #a36308; }

/* ---- TICKET ELEMENTS ---- */
.ticket-num { font-family: 'Courier New', monospace; font-weight: 700; color: var(--primary-dark); font-size: 13px; letter-spacing: 0.5px; }
.ticket-num-lg { font-family: 'Courier New', monospace; font-size: 18px; font-weight: 800; color: var(--primary-dark); }
.td-subject { max-width: 280px; font-weight: 600; color: var(--text-dark); }
.customer-cell { display: flex; flex-direction: column; gap: 2px; }
.cat-badge { padding: 3px 10px; border-radius: 50px; font-size: 11px; font-weight: 700; }
.sla-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 6px; animation: pulse 1.5s infinite; }
.sla-warning { background: var(--warning); }
.sla-breach  { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }
.text-warning { color: var(--warning) !important; }
.text-breach  { color: var(--danger) !important; }

/* ---- TICKET DETAIL ---- */
.ticket-header-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.ticket-detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.ticket-main { display: flex; flex-direction: column; }
.ticket-sidebar { display: flex; flex-direction: column; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 16px 20px; }
.info-item label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 3px; font-weight: 700; }
.info-item span  { font-size: 13px; color: var(--text-dark); font-weight: 600; }
.info-item a     { color: var(--primary); text-decoration: none; }

/* Messages */
.messages-thread { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; }
.msg-item { display: flex; gap: 12px; }
.msg-agent .msg-avatar { background: var(--primary); }
.msg-customer .msg-avatar { background: var(--success); }
.msg-avatar { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.msg-body { flex: 1; }
.msg-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.msg-name { font-size: 13px; font-weight: 700; color: var(--text-dark); }
.msg-role-badge { font-size: 10px; padding: 2px 8px; border-radius: 4px; font-weight: 700; text-transform: uppercase; }
.msg-role-badge.agent    { background: rgba(26,158,151,0.15); color: var(--primary-dark); }
.msg-role-badge.customer { background: rgba(46,158,110,0.15); color: #1f7a52; }
.msg-internal-badge { font-size: 10px; padding: 2px 8px; border-radius: 4px; background: rgba(212,133,10,0.15); color: #a36308; }
.msg-time { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.msg-content { background: rgba(26,158,151,0.05); border-radius: 10px; padding: 12px 16px; font-size: 13px; color: var(--text-body); line-height: 1.7; border-left: 3px solid var(--border); }
.msg-agent .msg-content    { border-left-color: var(--primary); }
.msg-customer .msg-content { border-left-color: var(--success); background: rgba(46,158,110,0.05); }
.msg-internal .msg-content { border-left-color: var(--warning); background: rgba(212,133,10,0.05); }
.msg-system { text-align: center; font-size: 12px; color: var(--text-muted); padding: 8px; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); }
.empty-msg { text-align: center; padding: 20px; color: var(--text-muted); font-size: 13px; }

/* Reply box */
.reply-box { padding: 16px 20px; border-top: 1px solid var(--border); background: rgba(26,158,151,0.02); }
.reply-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.reply-tab { padding: 6px 14px; border-radius: 8px; border: 1.5px solid var(--border); background: #fff; color: var(--text-muted); font-family: 'Bai Jamjuree', sans-serif; font-size: 13px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.reply-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.reply-textarea { min-height: 100px; }
.reply-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.closed-notice { padding: 16px 20px; text-align: center; color: var(--text-muted); font-size: 13px; border-top: 1px solid var(--border); }

/* History */
.history-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto; }
.history-item { padding: 10px 12px; background: rgba(26,158,151,0.04); border-radius: 8px; border-left: 2px solid var(--border); }
.history-action { font-size: 13px; color: var(--text-dark); font-weight: 600; }
.history-change { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; }
.history-change span { padding: 2px 8px; border-radius: 4px; background: rgba(26,158,151,0.1); color: var(--text-body); }
.history-change i { color: var(--text-muted); font-size: 10px; }
.history-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ---- PAGINATION ---- */
.pagination { display: flex; gap: 4px; padding: 16px 20px; justify-content: center; }
.page-btn { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; text-decoration: none; color: var(--text-muted); background: #fff; border: 1.5px solid var(--border); transition: 0.2s; }
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- MODAL ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(28,59,56,0.5); z-index: 1000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.modal-overlay.show { display: flex; }
.modal-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 560px; animation: popIn 0.25s ease; box-shadow: var(--shadow); }
@keyframes popIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 18px; font-weight: 800; color: var(--text-dark); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; font-size: 18px; }
.modal-close:hover { color: var(--danger); }

/* ---- REPORTS ---- */
.reports-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.report-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.report-bar-label { width: 140px; font-size: 13px; flex-shrink: 0; font-weight: 600; }
.report-bar-track { flex: 1; height: 8px; background: rgba(26,158,151,0.1); border-radius: 4px; overflow: hidden; }
.report-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; background: var(--primary); }
.report-bar-count { width: 32px; text-align: right; font-size: 13px; font-weight: 700; color: var(--text-dark); }
.progress-wrap { height: 6px; background: rgba(26,158,151,0.1); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 3px; }
.daily-chart { display: flex; align-items: flex-end; gap: 4px; height: 100px; padding: 0 4px; }
.daily-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.daily-bar-value { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.daily-bar { width: 100%; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 4px; opacity: 0.75; transition: opacity 0.2s; }
.daily-bar-col:hover .daily-bar { opacity: 1; }
.daily-bar-label { font-size: 10px; color: var(--text-muted); font-weight: 600; }

/* ---- SETTINGS ---- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---- USER CELL ---- */
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar-sm { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; background: var(--primary); }

/* ---- LOGIN PAGE ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; position: relative; overflow: hidden; background: linear-gradient(135deg, #d8f0ed, #e8f4f0, #f0ede6); }
.login-bg { position: fixed; inset: 0; pointer-events: none; }
.login-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.3; }
.login-orb-1 { width: 400px; height: 400px; background: var(--primary); top: -100px; left: -100px; }
.login-orb-2 { width: 300px; height: 300px; background: #8ecdc9; bottom: -80px; right: -80px; }
.login-wrapper { position: relative; z-index: 1; width: 100%; max-width: 420px; }
.login-card { background: rgba(255,255,255,0.85); border: 1px solid var(--border); border-radius: 20px; padding: 40px; box-shadow: 0 8px 40px rgba(26,158,151,0.15); backdrop-filter: blur(10px); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-icon { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 28px; color: #fff; box-shadow: 0 6px 20px var(--primary-glow); }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--text-dark); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.login-form .form-group label { text-transform: none; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.login-footer { text-align: center; margin-top: 20px; }
.login-portal-link { font-size: 12px; color: var(--text-muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: 0.2s; font-weight: 600; }
.login-portal-link:hover { color: var(--primary); }

/* ---- UX ENHANCEMENTS ---- */

/* Smooth page transitions */
.main-content { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Loading spinner */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(26,158,151,0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-loading { position: relative; pointer-events: none; }
.btn-loading::after { content:''; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* Tooltip */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--text-dark); color: #fff; font-size: 11px; font-weight: 600; padding: 5px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.15s, transform 0.15s; transform: translateX(-50%) translateY(4px); z-index: 999; }
[data-tooltip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Focus ring — accessibility */
*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* Skeleton loader */
.skeleton { background: linear-gradient(90deg, var(--bg-card2) 25%, var(--bg-hover) 50%, var(--bg-card2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-row { height: 14px; margin-bottom: 8px; }
.skeleton-row.wide  { width: 70%; }
.skeleton-row.medium{ width: 45%; }
.skeleton-row.short { width: 25%; }

/* Card hover lift — interactive cards */
.card-interactive { cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
.card-interactive:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(26,158,151,0.15); border-color: var(--primary); }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--primary); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--border); }

/* Step indicator */
.steps { display: flex; gap: 0; margin-bottom: 24px; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.step::before { content:''; position: absolute; top: 16px; left: 50%; right: -50%; height: 2px; background: var(--border); z-index: 0; }
.step:last-child::before { display: none; }
.step-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-card2); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--text-muted); z-index: 1; transition: 0.25s; }
.step.done .step-dot  { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.active .step-dot{ background: #fff; border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glow); }
.step-label { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-top: 6px; text-align: center; }
.step.active .step-label, .step.done .step-label { color: var(--primary-dark); }

/* Tag / Chip */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 50px; font-size: 12px; font-weight: 600; background: var(--bg-card2); border: 1px solid var(--border); color: var(--text-secondary); }
.tag-remove { cursor: pointer; color: var(--text-muted); transition: color 0.2s; }
.tag-remove:hover { color: var(--danger); }
.tag-primary { background: rgba(26,158,151,0.1); border-color: rgba(26,158,151,0.25); color: var(--primary-dark); }

/* Count badge on nav */
.nav-count { margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 50px; min-width: 18px; text-align: center; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.divider-text { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.divider-text::before, .divider-text::after { content:''; flex:1; height:1px; background: var(--border); }

/* Inline status dot */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-online  { background: var(--success); box-shadow: 0 0 0 3px rgba(46,158,110,0.2); }
.dot-away    { background: var(--warning); }
.dot-offline { background: var(--text-muted); }

/* Better select arrow */
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a9e9b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* Input icon prefix */
.input-icon-wrap { position: relative; }
.input-icon-wrap .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; pointer-events: none; }
.input-icon-wrap .form-control { padding-left: 38px; }

/* Notification badge on cards */
.card-badge { position: absolute; top: -8px; right: -8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 50px; border: 2px solid var(--bg-main); }

/* Smooth accordion */
.accordion-body { overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.accordion-body.open { max-height: 600px; }
.accordion-header { cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; }
.accordion-header:hover { background: var(--bg-hover); }
.accordion-icon { transition: transform 0.25s; color: var(--text-muted); }
.accordion-header.open .accordion-icon { transform: rotate(180deg); }

/* Soft shadow ring on focus inputs */
.form-control:focus { box-shadow: 0 0 0 3px var(--primary-glow), 0 1px 3px rgba(26,158,151,0.1); }

/* Better required asterisk */
.required::after { content: ' *'; color: var(--danger); font-size: 12px; }

/* Ticket row clickable */
.ticket-row { cursor: pointer; transition: background 0.15s; }
.ticket-row:hover td { background: rgba(26,158,151,0.05); }
.ticket-row td:first-child { border-left: 3px solid transparent; }
.ticket-row:hover td:first-child { border-left-color: var(--primary); }

/* Priority dot on table */
.priority-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.priority-dot.low      { background: var(--success); }
.priority-dot.medium   { background: var(--warning); }
.priority-dot.high     { background: var(--danger); }
.priority-dot.critical { background: #8b0000; box-shadow: 0 0 6px rgba(139,0,0,0.4); }

/* Toast notification (top-right) */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; box-shadow: 0 8px 24px rgba(26,158,151,0.15); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 360px; pointer-events: all; animation: toastIn 0.3s ease; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--primary); }
@keyframes toastIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* Kbd shortcut hint */
kbd { background: var(--bg-card2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; font-size: 11px; font-family: monospace; color: var(--text-secondary); box-shadow: 0 1px 0 var(--border); }

/* ---- UTILITIES ---- */
.text-muted { color: var(--text-muted) !important; }
.text-sm  { font-size: 12px !important; }
.text-xs  { font-size: 11px !important; }
.mt-8  { margin-top: 8px !important; }
.mt-12 { margin-top: 12px !important; }
.mt-16 { margin-top: 16px !important; }
.mt-20 { margin-top: 20px !important; }
.mt-24 { margin-top: 24px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-24 { margin-bottom: 24px !important; }
.mb-16 { margin-bottom: 16px !important; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; display: block; margin-bottom: 12px; opacity: 0.25; color: var(--primary); }

/* ---- MOBILE TOP BAR ---- */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: 56px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(26,158,151,0.2);
}
.mobile-topbar-logo { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 800; color: #fff; }
.mobile-topbar-logo i { font-size: 20px; }
.mobile-menu-btn { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 40px; height: 40px; border-radius: 10px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* ---- SIDEBAR OVERLAY (mobile) ---- */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(28,59,56,0.5); z-index: 150; backdrop-filter: blur(2px); }
.sidebar-overlay.show { display: block; }

/* ---- BOTTOM NAV (mobile) ---- */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(26,158,151,0.1);
}
.bottom-nav-inner { display: flex; justify-content: space-around; align-items: center; }
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 12px; text-decoration: none; color: var(--text-muted); font-size: 10px; font-weight: 700; border-radius: 10px; transition: color 0.2s; min-width: 56px; }
.bottom-nav-item i { font-size: 20px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item span { font-size: 10px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }

@media (max-width: 1024px) {
  .ticket-detail-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }
}

/* Tablet */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .main-content { padding: 20px; }
}

/* Mobile */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  /* Show mobile topbar */
  .mobile-topbar { display: flex; }

  /* Sidebar slides in/out */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    z-index: 160;
    width: var(--sidebar-w);
    top: 0;
  }
  .sidebar.open { transform: translateX(0); }

  /* Main content full width, pushed below topbar + above bottom nav */
  .main-content {
    margin-left: 0;
    padding: 72px 14px 80px;
    max-width: 100vw;
  }

  /* Bottom nav */
  .bottom-nav { display: block; }

  /* Grids → single column */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .ticket-detail-grid { grid-template-columns: 1fr; gap: 12px; }
  .settings-grid { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }

  /* Page header stack */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
  .page-title { font-size: 18px; }

  /* Filter bar scroll */
  .filter-form { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .filter-search { min-width: 160px; }
  .filter-select { min-width: 120px; flex-shrink: 0; }

  /* Table horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 640px; }

  /* Touch targets */
  .btn { min-height: 42px; }
  .form-control { min-height: 44px; font-size: 16px; } /* prevent iOS zoom */

  /* Ticket detail */
  .ticket-header-badges { flex-wrap: wrap; gap: 6px; }
  .info-grid { grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }

  /* KPI value smaller */
  .kpi-value { font-size: 24px; }
  .kpi-card { padding: 14px 12px; }

  /* Hide text labels on bottom nav if very small */
  .page-subtitle { display: none; }
}

/* Very small phones */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 20px; }
  .bottom-nav-item span { display: none; }
  .bottom-nav-item { padding: 8px; }
  .main-content { padding: 68px 10px 72px; }
}
