/* =================== PORTAL SHARED CSS =================== */
/* Used by both customer and staff static portals on Cloudflare Pages */

* { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
body { margin: 0; padding: 0; background: #f4f6f9; }

/* ---------- Login Page ---------- */
body.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0078D4 0%, #106EBE 50%, #005a9e 100%);
  position: relative; overflow-y: auto; padding: 16px 0;
}
body.login-page::before {
  content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at 30% 50%, rgba(0,200,255,0.06) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(255,255,255,0.04) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}
.login-wrapper { position: relative; z-index: 1; width: 420px; max-width: 100%; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, #0078D4 0%, #005a9e 100%);
  box-shadow: 0 8px 24px rgba(0,120,212,0.3); margin-bottom: 12px;
}
.login-logo .logo-icon i { font-size: 28px; color: #fff; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: #fff; margin: 0; letter-spacing: -0.3px; }
.login-logo p { font-size: 13px; color: rgba(255,255,255,0.5); margin: 4px 0 0; font-weight: 400; }
.login-card {
  background: rgba(255,255,255,0.98); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.login-card-body { padding: 36px 32px; }
.form-label { font-size: 13px; font-weight: 600; color: #495057; margin-bottom: 6px; }
.input-group { margin-bottom: 20px; }
.input-group-text {
  background: #f8f9fa; border: 1px solid #dee2e6; border-right: none;
  border-radius: 10px 0 0 10px; padding: 0 14px; color: #6c757d;
}
.form-control {
  border: 1px solid #dee2e6; border-left: none; border-radius: 0 10px 10px 0;
  padding: 12px 14px; font-size: 14px; height: 44px; transition: all 0.2s; background: #f8f9fa; width: 100%;
}
.form-control:focus { border-color: #0078D4; box-shadow: none; background: #fff; outline: none; }
.input-group:focus-within .input-group-text { border-color: #0078D4; background: #fff; }
.btn-login {
  background: linear-gradient(135deg, #0078D4 0%, #005a9e 100%);
  border: none; border-radius: 10px; padding: 12px; font-size: 15px;
  font-weight: 600; letter-spacing: 0.3px; height: 46px; width: 100%; color: #fff; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,120,212,0.25); transition: all 0.2s;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,120,212,0.35); }
.btn-login:active { transform: translateY(0); }
.alert-login { border-radius: 10px; border: none; font-size: 13px; background: #fff5f5; color: #c92a2a; padding: 12px 14px; margin-bottom: 16px; display: none; }
.alert-login.show { display: block; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: rgba(255,255,255,0.4); font-weight: 400; }
.login-footer a { color: rgba(255,255,255,0.6); text-decoration: none; }
.divider { height: 1px; background: #f1f3f5; margin: 8px 0 20px; }
.back-link { text-align: center; margin-top: 16px; }
.back-link a { font-size: 13px; color: #0078D4; text-decoration: none; font-weight: 500; }
.btn-azure {
  background: #fff; color: #0078D4; border: 1px solid #0078D4; border-radius: 10px;
  padding: 12px; font-size: 14px; font-weight: 600; width: 100%; cursor: pointer; margin-top: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s;
}
.btn-azure:hover { background: #f0f7ff; }

/* Staff login green theme */
body.login-page.staff-login { background: linear-gradient(135deg, #28a745 0%, #1e7e34 50%, #155724 100%); }
body.login-page.staff-login .login-logo .logo-icon { background: linear-gradient(135deg, #28a745 0%, #155724 100%); box-shadow: 0 8px 24px rgba(40,167,69,0.3); }
body.login-page.staff-login .btn-login { background: linear-gradient(135deg, #28a745 0%, #155724 100%); box-shadow: 0 4px 12px rgba(40,167,69,0.25); }
body.login-page.staff-login .form-control:focus { border-color: #28a745; }
body.login-page.staff-login .input-group:focus-within .input-group-text { border-color: #28a745; }
body.login-page.staff-login .back-link a { color: #28a745; }

@media (max-width: 480px) {
  .login-wrapper { width: 100%; padding: 0 16px; }
  .login-card-body { padding: 24px 18px; }
}

/* ---------- Portal Navbar ---------- */
.navbar-portal {
  background: linear-gradient(90deg, #0078D4, #005a9e); color: #fff;
  padding: 0 20px; height: 56px; display: flex; align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15); position: sticky; top: 0; z-index: 1000;
}
.navbar-portal.staff { background: linear-gradient(90deg, #28a745, #155724); }
.navbar-portal .brand { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; }
.navbar-portal .brand img { height: 28px; border-radius: 4px; }
.navbar-portal .nav-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.navbar-portal .nav-right .user-name { font-size: 14px; font-weight: 500; }
.navbar-portal .nav-right .auth-badge { font-size: 11px; background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 10px; }
.navbar-portal .nav-right a, .navbar-portal .nav-right button {
  color: #fff; text-decoration: none; font-size: 14px; background: none; border: none; cursor: pointer;
  padding: 6px 12px; border-radius: 6px; transition: background 0.2s;
}
.navbar-portal .nav-right a:hover, .navbar-portal .nav-right button:hover { background: rgba(255,255,255,0.15); }

/* ---------- Content ---------- */
.content-wrapper { padding: 20px; max-width: 1400px; margin: 0 auto; }
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.content-header h1 { font-size: 24px; font-weight: 700; color: #2c3e50; margin: 0; }
.content-header .btn-new {
  background: #0078D4; color: #fff; border: none; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background 0.2s;
}
.content-header .btn-new:hover { background: #0069c0; }
.content-header .btn-new.staff { background: #28a745; }
.content-header .btn-new.staff:hover { background: #1e7e34; }

/* ---------- Stat Cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex; align-items: center; gap: 16px; transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; flex-shrink: 0;
}
.stat-card .stat-info .stat-value { font-size: 28px; font-weight: 700; color: #2c3e50; line-height: 1; }
.stat-card .stat-info .stat-label { font-size: 12px; color: #6c757d; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.total .stat-icon { background: #0078D4; }
.stat-card.open .stat-icon { background: #ffc107; }
.stat-card.in-progress .stat-icon { background: #17a2b8; }
.stat-card.resolved .stat-icon { background: #28a745; }
.stat-card.closed .stat-icon { background: #6c757d; }
.stat-card.overdue .stat-icon { background: #dc3545; }

/* ---------- Filters ---------- */
.filter-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filter-row input[type="text"], .filter-row select {
  padding: 10px 14px; border: 1px solid #dee2e6; border-radius: 8px; font-size: 14px; background: #fff; outline: none;
}
.filter-row input[type="text"] { flex: 1; min-width: 200px; }
.filter-row input[type="text"]:focus, .filter-row select:focus { border-color: #0078D4; }
.filter-row .badge-count { font-size: 13px; color: #6c757d; margin-left: auto; }

/* ---------- Ticket Cards ---------- */
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.ticket-card {
  background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; border-left: 4px solid #0078D4;
}
.ticket-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.ticket-card.priority-urgent { border-left-color: #dc3545; }
.ticket-card.priority-high { border-left-color: #fd7e14; }
.ticket-card.priority-normal { border-left-color: #0078D4; }
.ticket-card.priority-low { border-left-color: #28a745; }
.ticket-card .ticket-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 8px; }
.ticket-card .ticket-id { font-size: 12px; color: #6c757d; font-weight: 600; }
.ticket-card .ticket-subject { font-size: 16px; font-weight: 600; color: #2c3e50; margin: 4px 0 8px; }
.ticket-card .ticket-meta { display: flex; gap: 12px; font-size: 12px; color: #6c757d; flex-wrap: wrap; }
.ticket-card .ticket-meta .meta-item { display: flex; align-items: center; gap: 4px; }
.ticket-card .ticket-status { font-size: 11px; padding: 3px 10px; border-radius: 10px; font-weight: 600; }
.status-new { background: #e3f2fd; color: #0078D4; }
.status-in-progress { background: #e0f7fa; color: #17a2b8; }
.status-resolved { background: #e8f5e9; color: #28a745; }
.status-closed { background: #f5f5f5; color: #6c757d; }
.status-feedback { background: #fff3e0; color: #ff9800; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); display: none; align-items: flex-start; justify-content: center;
  z-index: 2000; padding: 20px; overflow-y: auto;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px; max-width: 800px; width: 100%; margin: 20px 0;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden;
}
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 18px; font-weight: 700; margin: 0; color: #2c3e50; }
.modal-header .close-btn { background: none; border: none; font-size: 22px; color: #6c757d; cursor: pointer; padding: 4px 8px; }
.modal-header .close-btn:hover { color: #dc3545; }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 12px; }

/* ---------- Form ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #495057; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; border: 1px solid #dee2e6; border-radius: 8px; font-size: 14px; outline: none; transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #0078D4; }
.form-group textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.btn-primary {
  background: #0078D4; color: #fff; border: none; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: #0069c0; }
.btn-primary.staff { background: #28a745; }
.btn-primary.staff:hover { background: #1e7e34; }
.btn-secondary { background: #e9ecef; color: #495057; border: none; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-secondary:hover { background: #dee2e6; }
.btn-danger { background: #dc3545; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; font-size: 13px; cursor: pointer; }

/* ---------- Ticket Detail ---------- */
.detail-section { margin-bottom: 20px; }
.detail-section h4 { font-size: 14px; font-weight: 700; color: #2c3e50; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-item .label { font-size: 12px; color: #6c757d; text-transform: uppercase; }
.detail-item .value { font-size: 14px; color: #2c3e50; font-weight: 500; }
.detail-description { background: #f8f9fa; border-radius: 8px; padding: 16px; font-size: 14px; line-height: 1.6; color: #2c3e50; }
.rich-content { line-height: 1.6; }
.rich-content img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.rich-content p { margin: 8px 0; }
.rich-content ul, .rich-content ol { margin: 8px 0; padding-left: 24px; }
.rich-content pre { background: #f1f3f5; padding: 12px; border-radius: 8px; overflow-x: auto; }
.rich-content blockquote { border-left: 3px solid #dee2e6; padding-left: 12px; color: #6c757d; margin: 8px 0; }
.rich-content table { border-collapse: collapse; width: 100%; }
.rich-content th, .rich-content td { border: 1px solid #dee2e6; padding: 8px; }
.rich-content a { color: #0078D4; }

/* ---------- Notes ---------- */
.note-item { background: #f8f9fa; border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; border-left: 3px solid #0078D4; }
.note-item .note-meta { font-size: 12px; color: #6c757d; margin-bottom: 4px; }
.note-item .note-body { font-size: 14px; color: #2c3e50; }
.note-item.staff-note { border-left-color: #28a745; }

/* ---------- Attachments ---------- */
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px; background: #e9ecef; padding: 6px 12px;
  border-radius: 20px; font-size: 13px; color: #495057; text-decoration: none; transition: background 0.2s;
}
.attachment-chip:hover { background: #dee2e6; }
.attachment-chip i { color: #0078D4; }

/* ---------- Progress Slider ---------- */
.progress-slider { width: 100%; }
.progress-slider input[type="range"] { width: 100%; }
.progress-value { font-size: 14px; font-weight: 600; color: #0078D4; text-align: center; }

/* ---------- Toast ---------- */
.toast-msg {
  position: fixed; bottom: 24px; right: 24px; background: #2c3e50; color: #fff;
  padding: 14px 20px; border-radius: 10px; font-size: 14px; z-index: 3000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); display: none; align-items: center; gap: 8px;
}
.toast-msg.show { display: flex; }
.toast-msg.success { background: #28a745; }
.toast-msg.error { background: #dc3545; }

/* ---------- Session Banner ---------- */
.session-banner {
  position: fixed; top: 56px; left: 0; right: 0; z-index: 1500;
  background: linear-gradient(90deg, #ff9800, #f57c00); color: #fff;
  padding: 10px 20px; display: none; align-items: center; justify-content: center; gap: 12px;
  font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.session-banner .countdown { font-weight: 700; font-size: 16px; }
.session-banner .btn-extend {
  background: #fff; color: #f57c00; border: none; padding: 4px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.session-banner .btn-extend:hover { background: #fff3e0; }
.session-banner .btn-logout {
  background: rgba(255,255,255,0.2); color: #fff; border: none; padding: 4px 14px; border-radius: 6px;
  font-size: 13px; cursor: pointer;
}

/* ---------- Session Expired Modal ---------- */
.session-modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center;
  z-index: 2500;
}
.session-modal-overlay.show { display: flex; }
.session-modal-box {
  background: #fff; border-radius: 16px; padding: 40px; max-width: 420px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.session-modal-box .icon { font-size: 48px; color: #dc3545; margin-bottom: 16px; }
.session-modal-box h3 { font-size: 22px; font-weight: 700; color: #2c3e50; margin: 0 0 8px; }
.session-modal-box p { font-size: 14px; color: #6c757d; margin: 0 0 24px; }
.session-modal-box .btn-login-again {
  background: #0078D4; color: #fff; border: none; padding: 12px 32px; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.session-modal-box .btn-login-again:hover { background: #0069c0; }

/* ---------- Empty State ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: #6c757d; }
.empty-state i { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; }

/* ---------- Loading ---------- */
.loading-spinner { text-align: center; padding: 40px; color: #6c757d; }
.loading-spinner .spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid #e9ecef; border-top-color: #0078D4; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  .ticket-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .navbar-portal .nav-right .user-name { display: none; }
}
@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr; }
  .content-wrapper { padding: 12px; }
}
