/* ============================================================
   Panel Klienta SBFlor — panel.css
   /public/css/panel.css
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ── ZMIENNE ─────────────────────────────────────────────── */
:root {
  --bg:           #f5f5f2;
  --surface:      #ffffff;
  --surface2:     #f9f9f7;
  --border:       #e8e8e4;
  --border2:      #d8d8d2;
  --text:         #1a1a18;
  --text2:        #6b6b65;
  --text3:        #9b9b94;
  --accent:       #2563eb;
  --accent-light: #eff6ff;
  --accent-hover: #1d4ed8;
  --green:        #16a34a;
  --green-bg:     #f0fdf4;
  --orange:       #ea580c;
  --orange-bg:    #fff7ed;
  --red:          #dc2626;
  --red-bg:       #fef2f2;
  --yellow:       #d97706;
  --yellow-bg:    #fffbeb;
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --radius:       10px;
  --shadow:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ── LOGIN ────────────────────────────────────────────────── */
.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo .logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
}

.login-logo span { font-size: 18px; font-weight: 600; letter-spacing: -.3px; }

.login-card h1  { font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.4px; }
.login-card > p { color: var(--text2); margin-bottom: 28px; font-size: 13.5px; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-group       { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text2); cursor: pointer;
}
.checkbox-label input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.link { color: var(--accent); font-size: 13px; text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

.btn-primary {
  width: 100%; padding: 11px;
  background: var(--accent);
  color: white; border: none;
  border-radius: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
}
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.98); }

/* ── APP LAYOUT ───────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 18px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo .logo-mark {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: white;
}

.sidebar-logo span { font-size: 15px; font-weight: 700; letter-spacing: -.3px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; margin: 1px 8px;
  border-radius: 7px; cursor: pointer;
  color: var(--text2); font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s;
  text-decoration: none;
}

.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item.active svg { color: var(--accent) !important; }

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text3); }

.nav-badge {
  margin-left: auto;
  background: var(--accent); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 20px;
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: background .12s;
  text-decoration: none; color: inherit;
}
.user-card:hover { background: var(--surface2); }

.user-info   { flex: 1; min-width: 0; }
.user-name   { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role   { font-size: 11px; color: var(--text3); }

/* TOPBAR */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  z-index: 90;
}

.topbar-title   { font-size: 15px; font-weight: 600; letter-spacing: -.2px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* MAIN */
.main {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  flex: 1;
  min-height: 100vh;
}

.page-content { padding: 28px; }

/* ── AVATARS & ICONS ──────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent);
  flex-shrink: 0;
}

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text2);
  transition: background .12s, color .12s;
  position: relative;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn svg   { width: 16px; height: 16px; }

.hamburger { display: none; }

.notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px;
  background: var(--red); border-radius: 50%;
  border: 1.5px solid white;
}

/* ── FLASH MESSAGES ───────────────────────────────────────── */
.flash {
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 20px; font-size: 13.5px; font-weight: 500;
}
.flash-success { background: var(--green-bg);  color: var(--green); border: 1px solid #bbf7d0; }
.flash-error   { background: var(--red-bg);    color: var(--red);   border: 1px solid #fecaca; }
.flash-warning { background: var(--yellow-bg); color: var(--yellow);border: 1px solid #fde68a; }

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title { font-size: 14px; font-weight: 600; }
.card-sub   { font-size: 12px; color: var(--text3); margin-top: 2px; }
.card-body  { padding: 20px; }

/* ── GRIDS ────────────────────────────────────────────────── */
.grid-4   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3   { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2   { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.gap-16   { display: flex; flex-direction: column; gap: 16px; }

/* ── STAT CARDS ───────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.5px; line-height: 1; margin-bottom: 6px; }
.stat-sub   { font-size: 12px; color: var(--text2); }
.stat-icon  { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-blue   { background: var(--accent-light); color: var(--accent); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-gray   { background: var(--surface2);  color: var(--text2); border: 1px solid var(--border); }

/* ── PROGRESS ─────────────────────────────────────────────── */
.progress-bar {
  width: 100%; height: 6px;
  background: var(--border);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: var(--accent);
  transition: width .6s ease;
}
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text2);
  margin-bottom: 6px;
}

/* ── DAYS COUNTER ─────────────────────────────────────────── */
.days-counter { font-size: 13px; font-weight: 700; font-family: 'DM Mono', monospace; }
.days-ok      { color: var(--green); }
.days-warn    { color: var(--yellow); }
.days-crit    { color: var(--red); }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 7px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
  border: none; text-decoration: none; line-height: 1;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-sm     { padding: 5px 10px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }

.btn-primary-solid  { background: var(--accent); color: white; }
.btn-primary-solid:hover { background: var(--accent-hover); color: white; }

.btn-ghost  { background: transparent; color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-outline-accent { background: var(--accent-light); color: var(--accent); border: 1px solid #bfdbfe; }
.btn-outline-accent:hover { background: #dbeafe; }

/* ── TABLE ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}

td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; cursor: default; }
tbody tr:hover { background: var(--surface2); }

/* ── SECTION HEADER ───────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.section-title { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.section-sub   { font-size: 12px; color: var(--text3); margin-top: 3px; }

/* ── PROJECT CARDS ────────────────────────────────────────── */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  cursor: pointer; transition: box-shadow .15s, transform .1s;
  display: block;
}
.project-card:hover   { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.project-card-name    { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.project-card-meta    { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }

/* ── SERVICE CARDS ────────────────────────────────────────── */
.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.service-icon   { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.service-name   { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.service-domain { font-size: 12px; color: var(--text3); font-family: 'DM Mono', monospace; margin-bottom: 12px; }
.service-meta   { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.service-meta-item label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text3); margin-bottom: 3px; }
.service-meta-item span  { font-size: 13px; font-weight: 600; }

/* ── TICKET CHAT ──────────────────────────────────────────── */
.ticket-chat { display: flex; flex-direction: column; gap: 16px; }

.message-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px; line-height: 1.6;
  max-width: 80%;
}

.message-client {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  align-self: flex-start;
}

.message-agent {
  background: var(--accent); color: white;
  border-radius: 12px 12px 4px 12px;
  align-self: flex-end;
}

.message-meta       { font-size: 11px; color: var(--text3); margin-bottom: 4px; }
.message-meta.agent { text-align: right; }

.reply-box {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  display: flex; gap: 10px; align-items: flex-end;
}

.reply-textarea {
  flex: 1;
  border: 1.5px solid var(--border2);
  border-radius: 8px; padding: 10px 14px;
  font-family: inherit; font-size: 13.5px;
  resize: none; min-height: 80px; outline: none;
  transition: border-color .15s; color: var(--text);
  background: var(--surface);
}
.reply-textarea:focus { border-color: var(--accent); }

/* ── FILES ────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-light); }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

.file-item {
  border: 1.5px solid var(--border);
  border-radius: 8px; padding: 14px;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; text-align: center; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.file-item:hover { border-color: var(--accent); background: var(--accent-light); }

.file-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.file-name { font-size: 12px; font-weight: 500; word-break: break-all; }
.file-size { font-size: 11px; color: var(--text3); }

/* ── NOTIFICATIONS ────────────────────────────────────────── */
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200; display: none; overflow: hidden;
}
.notif-dropdown.open { display: block; }

.notif-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s;
  display: flex; gap: 10px; align-items: flex-start;
}
.notif-item:hover      { background: var(--surface2); }
.notif-item:last-child { border-bottom: none; }
.notif-item.read       { opacity: .75; }

.notif-dot-badge { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 5px; }
.notif-dot-badge.read { background: transparent; border: 1.5px solid var(--border2); }

.notif-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-body  { font-size: 12px; color: var(--text2); line-height: 1.5; }
.notif-time  { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── STAGES ───────────────────────────────────────────────── */
.stage-list { display: flex; flex-direction: column; gap: 8px; }

.stage-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border);
}

.stage-check {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stage-check.done    { background: var(--green); }
.stage-check.pending { background: var(--border2); }

.stage-name      { font-size: 13.5px; font-weight: 500; }
.stage-name.done { text-decoration: line-through; color: var(--text3); }

/* ── MISC ─────────────────────────────────────────────────── */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text2); font-size: 13px; cursor: pointer;
  margin-bottom: 20px; padding: 6px 10px; border-radius: 7px;
  transition: background .1s; text-decoration: none;
}
.back-btn:hover { background: var(--surface2); color: var(--text); }
.back-btn svg   { width: 14px; height: 14px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 99;
}

/* ── ANIMATIONS ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-content { animation: fadeIn .2s ease; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .grid-3   { grid-template-columns: repeat(2, 1fr); }
  .grid-1-2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }

  .topbar { left: 0; padding: 0 16px; }
  .main   { margin-left: 0; }
  .page-content { padding: 16px; }

  .grid-4   { grid-template-columns: 1fr 1fr; }
  .grid-3   { grid-template-columns: 1fr; }
  .grid-2   { grid-template-columns: 1fr; }
  .grid-1-2 { grid-template-columns: 1fr; }

  .hamburger  { display: flex !important; }
  .login-card { padding: 32px 24px; margin: 16px; }

  .message-bubble { max-width: 90%; }
  .notif-dropdown { width: calc(100vw - 32px); right: -8px; }
}

/* Sortowanie tabel */
.sortable-table th.sort-asc::after {
    content: ' ↑';
    font-size: 11px;
    opacity: 0.7;
}
.sortable-table th.sort-desc::after {
    content: ' ↓';
    font-size: 11px;
    opacity: 0.7;
}
.sortable-table th {
    user-select: none;
}
.priority-select {
    transition: all 0.2s ease;
}
.priority-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}