/* ============================================================
   TICKET PORTAL - Stylesheet
   ============================================================ */

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

:root {
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --border: #E9ECEF;
    --border-light: #F1F3F5;
    --text: #1A1A1A;
    --text-secondary: #495057;
    --text-muted: #868E96;
    --text-faint: #ADB5BD;
    --accent: #1A1A1A;
    --accent-text: #FFFFFF;
    --blue: #1971C2;
    --blue-bg: #E7F5FF;
    --orange: #E8590C;
    --orange-bg: #FFF4E6;
    --purple: #9C36B5;
    --purple-bg: #F8F0FC;
    --green: #2F9E44;
    --green-bg: #EBFBEE;
    --red: #C92A2A;
    --red-bg: #FFF5F5;
    --radius: 10px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --font: 'DM Sans', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 800px; margin: 0 auto; padding: 20px 16px; }

/* Header */
.header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo-mark {
    width: 40px; height: 40px; border-radius: var(--radius);
    background: var(--accent); color: var(--accent-text);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
}
.header h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.header-sub { font-size: 13px; color: var(--text-muted); margin: 0; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 20px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; font-family: var(--font);
    cursor: pointer; border: none; transition: opacity 0.15s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: 0.85; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost {
    background: none; border: 1px solid var(--border);
    color: var(--text-secondary); font-weight: 500;
}
.btn-danger { background: none; border: 1px solid #FFC9C9; color: var(--red); font-weight: 500; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-tiny {
    background: none; border: none; font-size: 12px; font-weight: 600;
    cursor: pointer; font-family: var(--font); color: var(--blue); padding: 4px 8px;
}

/* Cards */
.card {
    background: var(--surface); border-radius: 12px;
    padding: 24px; border: 1px solid var(--border);
}
.card-title { font-size: 18px; font-weight: 700; margin: 0 0 20px; letter-spacing: -0.02em; }

/* Forms */
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 20px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 200px; }
label, .label {
    display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em;
}
input[type="text"], input[type="password"], input[type="email"], textarea, select {
    width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); font-size: 14px; font-family: var(--font);
    outline: none; transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
textarea { resize: vertical; line-height: 1.6; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Chips (type/priority selectors) */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: none;
    font-size: 13px; font-weight: 500; cursor: pointer;
    font-family: var(--font); color: var(--text-muted); transition: all 0.15s;
}
.chip:hover { border-color: var(--text-faint); }
.chip.active {
    border-color: var(--accent); color: var(--accent);
    background: var(--bg); font-weight: 600;
}
.chip.active[data-color="orange"] { border-color: var(--orange); color: var(--orange); }
.chip.active[data-color="red"] { border-color: var(--red); color: var(--red); }
.chip.active[data-color="blue"] { border-color: var(--blue); color: var(--blue); }
.chip.active[data-color="gray"] { border-color: var(--text-muted); color: var(--text-muted); }

/* Filter bar */
.filter-bar {
    display: flex; gap: 4px; margin-bottom: 16px;
    background: var(--border-light); border-radius: var(--radius); padding: 4px;
}
.filter-btn {
    flex: 1; background: none; border: none; border-radius: var(--radius-sm);
    padding: 8px 12px; font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: var(--font); color: var(--text-muted);
    transition: all 0.15s;
}
.filter-btn.active {
    background: var(--surface); color: var(--text);
    font-weight: 600; box-shadow: var(--shadow-sm);
}

/* Ticket list */
.ticket-list { display: flex; flex-direction: column; gap: 6px; }
.ticket-row {
    display: flex; align-items: center; padding: 14px 16px;
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border-light); transition: all 0.15s;
    text-decoration: none; color: var(--text);
}
.ticket-row:hover { border-color: var(--border); text-decoration: none; box-shadow: var(--shadow-sm); }
.ticket-row-main { flex: 1; min-width: 0; }
.ticket-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.ticket-num {
    font-family: var(--mono); font-size: 12px;
    font-weight: 500; color: var(--text-faint);
}
.ticket-type { font-size: 12px; color: var(--text-muted); }
.ticket-title {
    font-size: 15px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ticket-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ticket-arrow { font-size: 20px; color: #CED4DA; margin-left: 12px; font-weight: 300; }

/* Status badges */
.status-badge {
    display: inline-block; font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: var(--radius-xs);
    letter-spacing: 0.02em; text-transform: uppercase;
}
.status-new { color: var(--orange); background: var(--orange-bg); }
.status-acknowledged { color: var(--blue); background: var(--blue-bg); }
.status-in-progress { color: var(--purple); background: var(--purple-bg); }
.status-complete { color: var(--green); background: var(--green-bg); }
.status-closed { color: var(--text-muted); background: var(--border-light); }

/* Priority indicators */
.priority { font-size: 11px; font-weight: 600; }
.priority-low { color: var(--text-muted); }
.priority-normal { color: var(--blue); }
.priority-high { color: var(--orange); }
.priority-urgent { color: var(--red); }

.ticket-time { font-size: 12px; color: var(--text-faint); }
.comment-count { font-size: 12px; color: var(--text-muted); }
.client-tag {
    font-size: 11px; font-weight: 500; color: var(--text-secondary);
    background: var(--border); padding: 2px 8px; border-radius: var(--radius-xs);
}

/* Client cards */
.client-grid { display: flex; flex-direction: column; gap: 8px; }
.client-card {
    display: flex; flex-direction: column; gap: 10px;
    padding: 16px 18px; background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border-light); transition: all 0.15s;
    text-decoration: none; color: var(--text);
}
.client-card:hover { border-color: var(--border); text-decoration: none; box-shadow: var(--shadow-sm); }
.client-card-top { display: flex; align-items: center; gap: 12px; }
.client-avatar {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--border); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.client-avatar.lg { width: 48px; height: 48px; font-size: 20px; }
.client-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.client-email { font-size: 12px; color: var(--text-faint); }
.client-stats { display: flex; align-items: center; gap: 6px; padding-left: 48px; }
.client-stat { font-size: 12px; color: var(--text-muted); }
.client-stat-sep { font-size: 12px; color: #DEE2E6; }

/* Client detail header */
.client-detail-header {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light);
}

/* Token box */
.token-box {
    background: var(--bg); border-radius: var(--radius);
    padding: 16px; margin-bottom: 20px; border: 1px solid var(--border);
}
.token-display {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; background: var(--surface);
    border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.token-code {
    font-family: var(--mono); font-size: 13px;
    letter-spacing: 0.03em; flex: 1; word-break: break-all; color: var(--text-secondary);
}

/* Ticket detail */
.detail-title {
    font-size: 22px; font-weight: 700; margin: 0 0 12px;
    letter-spacing: -0.02em; line-height: 1.3;
}
.detail-desc {
    font-size: 14px; line-height: 1.7; color: var(--text-secondary);
    margin-bottom: 20px; padding: 16px; background: var(--bg);
    border-radius: var(--radius-sm); white-space: pre-wrap;
}
.detail-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.meta-label {
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; min-width: 60px;
}
.meta-value { font-size: 13px; color: var(--text-secondary); }
.status-select { display: flex; gap: 4px; flex-wrap: wrap; }
.status-option {
    padding: 4px 10px; border-radius: var(--radius-xs);
    border: 1px solid transparent; font-size: 12px;
    cursor: pointer; font-family: var(--font); font-weight: 400;
    color: var(--text-muted); background: none; transition: all 0.15s;
}
.status-option:hover { background: var(--bg); }
.status-option.active { font-weight: 600; }

/* Comments */
.comments-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-light); }
.comments-title { font-size: 14px; font-weight: 600; margin: 0 0 16px; color: var(--text-secondary); }
.comment-bubble {
    padding: 12px 14px; background: var(--bg);
    border-radius: var(--radius); margin-bottom: 8px;
}
.comment-bubble.admin {
    border-left: 3px solid var(--blue); background: #F0F7FF;
}
.comment-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.comment-author {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.comment-author.admin { color: var(--blue); }
.comment-author.client { color: var(--text-muted); }
.comment-time { font-size: 11px; color: var(--text-faint); }
.comment-text { font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-wrap; }

/* File upload */
.drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 20px 16px; text-align: center; cursor: pointer;
    transition: all 0.15s; background: #FAFAFA;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--blue); background: var(--blue-bg);
}
.drop-zone-text { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.drop-zone-hint { font-size: 11px; color: var(--text-faint); display: block; margin-top: 4px; }
.drop-zone.compact { padding: 8px 12px; }

/* Attachment display */
.attach-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.attach-image-wrap {
    cursor: pointer; border-radius: var(--radius-sm);
    overflow: hidden; border: 1px solid var(--border); max-width: 200px;
}
.attach-image-wrap img {
    width: 100%; max-height: 160px; object-fit: cover; display: block;
}
.attach-image-name {
    font-size: 11px; color: var(--text-muted); padding: 4px 8px;
    display: block; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; background: #FAFAFA;
}
.attach-file-link {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; background: #FAFAFA; border-radius: var(--radius-sm);
    border: 1px solid var(--border); text-decoration: none; color: var(--text);
    min-width: 180px; max-width: 260px; transition: all 0.15s;
}
.attach-file-link:hover { border-color: var(--blue); text-decoration: none; }
.attach-file-icon { font-size: 18px; }
.attach-file-name {
    font-size: 13px; font-weight: 500; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.attach-file-size { font-size: 11px; color: var(--text-faint); }
.download-icon { font-size: 16px; color: var(--blue); font-weight: 700; }

/* Pending attachment thumbs */
.pending-attachments { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pending-thumb {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; background: var(--surface); border-radius: var(--radius-sm);
    border: 1px solid var(--border); font-size: 12px;
}
.pending-thumb .remove {
    background: none; border: none; color: var(--text-faint);
    cursor: pointer; font-size: 14px; padding: 0 2px;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); display: flex; align-items: center;
    justify-content: center; z-index: 9999; padding: 20px;
}
.lightbox-overlay img {
    max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: var(--radius-sm);
}
.lightbox-close {
    position: absolute; top: 20px; right: 20px;
    background: none; border: none; color: #fff; font-size: 28px;
    cursor: pointer; font-family: var(--font);
}
.lightbox-caption { text-align: center; color: var(--text-faint); font-size: 13px; margin-top: 8px; }

/* Login */
.login-wrap { max-width: 400px; margin: 0 auto; padding: 80px 20px; text-align: center; }
.login-logo {
    width: 56px; height: 56px; border-radius: 14px;
    background: var(--accent); color: var(--accent-text);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 700; margin-bottom: 20px;
}
.login-title { font-size: 24px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.03em; }
.login-sub { font-size: 14px; color: var(--text-muted); margin: 0 0 32px; }
.login-choices { display: flex; flex-direction: column; gap: 10px; }
.login-choice {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface);
    font-size: 14px; font-weight: 500; cursor: pointer;
    font-family: var(--font); color: var(--text); text-align: left;
    transition: all 0.15s; text-decoration: none;
}
.login-choice:hover { border-color: var(--text-faint); text-decoration: none; box-shadow: var(--shadow-sm); }
.login-choice-icon { font-size: 20px; }
.login-form { text-align: left; }
.login-hint { font-size: 12px; color: var(--text-faint); margin: 8px 0 0; }
.login-form-actions { display: flex; justify-content: space-between; margin-top: 16px; }
.auth-error { color: var(--red); font-size: 13px; margin: 8px 0 0; font-weight: 500; }
.token-input {
    font-family: var(--mono) !important; letter-spacing: 0.05em;
}

/* Section title */
.section-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 12px; }
.section-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}

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

/* Alert */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
    font-size: 13px; font-weight: 500;
}
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-error { background: var(--red-bg); color: var(--red); }

/* Rank controls */
.ticket-row-wrap {
    display: flex; align-items: center; gap: 0; margin-bottom: 6px;
}
.rank-controls {
    display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 8px 10px; min-width: 44px;
    background: var(--surface); border: 1px solid var(--border-light);
    border-right: none; border-radius: var(--radius) 0 0 var(--radius);
}
.rank-controls + .ticket-row {
    border-radius: 0 var(--radius) var(--radius) 0;
}
.rank-number {
    font-family: var(--mono); font-size: 14px; font-weight: 700;
    color: var(--text); line-height: 1; margin-bottom: 2px;
}
.rank-btn {
    background: none; border: 1px solid var(--border); border-radius: 4px;
    width: 24px; height: 20px; font-size: 9px; cursor: pointer;
    color: var(--text-secondary); display: inline-flex;
    align-items: center; justify-content: center;
    font-family: var(--font); padding: 0; transition: all 0.15s;
}
.rank-btn:hover:not(.disabled) { background: var(--blue-bg); border-color: var(--blue); color: var(--blue); }
.rank-btn.disabled { color: var(--border); border-color: var(--border-light); cursor: default; }

/* Responsive */
@media (max-width: 600px) {
    .header { flex-wrap: wrap; gap: 12px; }
    .field-row { flex-direction: column; gap: 0; }
    .field-row .field { min-width: unset; }
    .client-stats { padding-left: 0; }
    .status-select { gap: 2px; }
    .rank-controls { min-width: 36px; padding: 6px 6px; }
}
