/* ============================================================
   ระบบแจ้งปัญหาการใช้งานระบบสารสนเทศ - Stylesheet
   แนวคิด: โทนสี "Night Ops" - แถบข้างสีกรมท่าเข้ม (แรงบันดาลใจจาก
   ธีมเทอร์มินัล Tokyo Night) จับคู่กับพื้นที่ทำงานสีสว่างเพื่อการอ่าน
   ตารางและฟอร์มที่ชัดเจน เหมาะกับงานปฏิบัติการ IT ที่ต้องใช้สมาธิ
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --navy-950: #16161e;
    --navy-900: #1a1b26;
    --navy-800: #24283b;
    --navy-700: #2f334d;
    --ink-100: #c0caf5;
    --ink-300: #9aa5ce;

    --accent-blue: #7aa2f7;
    --accent-cyan: #7dcfff;
    --accent-green: #9ece6a;
    --accent-yellow: #e0af68;
    --accent-orange: #ff9e64;
    --accent-red: #f7768e;
    --accent-purple: #bb9af7;

    --bg-page: #f5f6fa;
    --bg-card: #ffffff;
    --border-soft: #e2e5f1;
    --text-main: #1f2338;
    --text-muted: #6b7092;

    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(22, 22, 30, 0.08);
    --shadow-md: 0 8px 24px rgba(22, 22, 30, 0.10);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Noto Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.6;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout: sidebar + main ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
    color: var(--ink-100);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 20px 8px;
    border-bottom: 1px solid var(--navy-700);
    margin-bottom: 18px;
}

.sidebar .brand .logo-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan);
    flex-shrink: 0;
}

.sidebar .brand-text { font-weight: 700; font-size: 15px; color: #fff; line-height: 1.3; }
.sidebar .brand-text small { display: block; font-weight: 400; color: var(--ink-300); font-size: 12px; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--ink-300);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 3px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover { background: var(--navy-800); color: #fff; }
.sidebar nav a.active { background: var(--navy-700); color: #fff; border-left: 3px solid var(--accent-cyan); padding-left: 9px; }
.sidebar nav .nav-icon { width: 18px; text-align: center; }

.sidebar .nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-300);
    opacity: 0.6;
    margin: 16px 12px 6px;
}

.sidebar .user-box {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--navy-700);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar .user-box .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-purple);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--navy-950); font-size: 14px; flex-shrink: 0;
}

.sidebar .user-box .info { flex: 1; min-width: 0; }
.sidebar .user-box .info .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user-box .info .role { font-size: 11px; color: var(--ink-300); }
.sidebar .user-box a.logout { color: var(--accent-red); font-size: 12px; margin-top: 2px; display: inline-block; }

.main-content { flex: 1; min-width: 0; }

.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-soft);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.page-body { padding: 26px 28px; max-width: 1200px; }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h2, .card-header h3 { margin: 0; font-size: 16px; font-weight: 700; }

/* ---------- Stat cards ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-left: 4px solid var(--accent-blue);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-card.accent-cyan { border-left-color: var(--accent-cyan); }
.stat-card.accent-yellow { border-left-color: var(--accent-yellow); }
.stat-card.accent-green { border-left-color: var(--accent-green); }
.stat-card.accent-red { border-left-color: var(--accent-red); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.form-group .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.18);
}

textarea.form-control { resize: vertical; min-height: 110px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s, transform 0.05s;
    font-family: inherit;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent-blue); color: #0f1224; }
.btn-secondary { background: var(--bg-page); color: var(--text-main); border: 1px solid var(--border-soft); }
.btn-success { background: var(--accent-green); color: #0f1224; }
.btn-danger { background: var(--accent-red); color: #2a0a10; }
.btn-warning { background: var(--accent-yellow); color: #2a1a05; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new { background: #e8ecfd; color: #3b5bdb; }
.badge-progress { background: #fff4e0; color: #b3730a; }
.badge-pending { background: #f1e8ff; color: #7c3aed; }
.badge-resolved { background: #e6f7ea; color: #2f9e44; }
.badge-closed { background: #ececf3; color: #495057; }
.badge-cancelled { background: #ffe3e8; color: #c9184a; }

.badge-priority-low { background: #ececf3; color: #495057; }
.badge-priority-medium { background: #e8ecfd; color: #3b5bdb; }
.badge-priority-high { background: #fff0e0; color: #d9640a; }
.badge-priority-urgent { background: #ffe3e8; color: #e0245e; }

.badge-sla-good { background: #e6f7ea; color: #2f9e44; }
.badge-sla-warning { background: #fff4e0; color: #b3730a; }
.badge-sla-danger { background: #ffe3e8; color: #c9184a; font-weight: 700; }
.badge-sla-na { background: #ececf3; color: #868e96; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-page);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-soft);
}
table.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
table.data-table tr:hover td { background: #fafbfe; }
table.data-table tr:last-child td { border-bottom: none; }

.ticket-link { font-weight: 600; color: var(--text-main); }
.ticket-link:hover { color: var(--accent-blue); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }

/* ---------- Alerts / Flash messages ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.alert-success { background: #e6f7ea; color: #2f9e44; }
.alert-danger { background: #ffe3e8; color: #c9184a; }
.alert-warning { background: #fff4e0; color: #b3730a; }
.alert-info { background: #e8ecfd; color: #3b5bdb; }

/* ---------- Auth pages (login/register) ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #24283b 0%, #16161e 60%);
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 36px 34px;
    width: 100%;
    max-width: 400px;
}

.auth-card .logo-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent-cyan); box-shadow: 0 0 14px var(--accent-cyan); display: inline-block; margin-bottom: 12px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card .subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.auth-card .switch-link { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }

/* ---------- Ticket detail / timeline ---------- */
.ticket-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ticket-header h2 { margin: 0 0 6px; font-size: 20px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 18px 0; }
.meta-item .meta-label { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.meta-item .meta-value { font-size: 14px; font-weight: 600; }

.attachment-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.attachment-chip {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-page); border: 1px solid var(--border-soft);
    border-radius: 8px; padding: 8px 12px; font-size: 13px;
}

.comment-item { padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.comment-item:last-child { border-bottom: none; }
.comment-item .comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-item .comment-author { font-weight: 700; font-size: 13px; }
.comment-item .comment-time { font-size: 12px; color: var(--text-muted); }
.comment-item.internal { background: #fff9ec; border-radius: 8px; padding: 12px 14px; border-bottom: none; margin-bottom: 8px; }
.internal-tag { font-size: 11px; background: var(--accent-yellow); color: #2a1a05; padding: 1px 8px; border-radius: 999px; font-weight: 700; }

.timeline-item { display: flex; gap: 12px; padding: 10px 0; font-size: 13px; }
.timeline-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-blue); margin-top: 6px; flex-shrink: 0; }
.timeline-item .content { color: var(--text-muted); }
.timeline-item .content b { color: var(--text-main); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 42px; margin-bottom: 12px; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: end; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

/* ---------- Star rating ---------- */
.star-rating { display: flex; gap: 4px; font-size: 22px; }
.star-rating .star { cursor: pointer; color: var(--border-soft); }
.star-rating .star.filled { color: var(--accent-yellow); }

@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 100; transition: left 0.2s; }
    .sidebar.open { left: 0; }
    .page-body { padding: 18px 16px; }
    .topbar { padding: 14px 16px; }
}
