/* === Variables & Base === */
:root {
  --bg-1: #e6f7ff;
  --bg-2: #f0f9ff;
  --card-bg: #ffffff;
  --muted: #334155;
  --accent-1: #7c3aed;
  --accent-2: #60a5fa;
  --text-main: #0f172a;
  --border-color: #e6edf2;
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --success-border: #86efac;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --error-border: #fca5a5;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* === Layout === */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.97);
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

header img {
  height: 34px;
  margin-right: 8px;
}

main {
  max-width: 1100px;
  margin: 96px auto 40px;
  padding: 18px 16px;
}

.site-footer {
  text-align: center;
  padding: 14px 16px 20px;
  color: #64748b;
  font-size: 0.85rem;
}

.center-vert {
  min-height: calc(100vh - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.content {
  margin-bottom: 18px;
}

/* === Components: Buttons === */
.btn,
button[type="submit"],
button[type="button"],
.btn-save,
.btn-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 10px;
  border: 0;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.1s, background-color 0.2s;
  font-size: 0.95rem;
  line-height: 1.2;
}

.btn:hover {
  opacity: 0.95;
}

.btn:active {
  transform: translateY(1px);
}

/* Primary Gradient Button (Login, Add Client, Search) */
.btn-primary,
.add-btn,
.login-form button[type="submit"],
.daniel .btn,
.search-form .btn {
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.16);
}

/* Solid Blue Button (Save) */
.btn-save {
  background-color: #3b82f6;
  color: white;
}

.btn-save:hover {
  background-color: #2563eb;
}

/* Secondary/Cancel Button */
.btn-cancel {
  background-color: #e2e8f0;
  color: #334155;
}

.btn-cancel:hover {
  background-color: #cbd5e1;
}

/* Secondary / Neutral Button */
.btn-secondary {
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
  background-color: #e2e8f0;
  border-color: #94a3b8;
}

/* Warning / Archive Button */
.btn-warning {
  background: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.18);
}

.btn-warning:hover {
  opacity: 0.97;
}

/* Outline Button (Logout) */
.btn-outline,
header .btn-logout {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
}

/* === Components: Cards === */
.card,
.profile-card,
.form-container {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
  padding: 28px;
  margin: 0 auto 40px;
  width: calc(100% - 36px);
  box-sizing: border-box;
}

/* Login Card Specifics */
.daniel .profile-card {
  max-width: 520px;
  margin-top: 96px;
  text-align: center;
}

/* Form Card Specifics */
.profile-card:not(.daniel .profile-card),
.form-container {
  max-width: 920px;
  margin-top: 18px;
}

/* Proxy Card (Nested) */
.proxy-card {
  background: #fff;
  border: 1px solid #e9eef6;
  padding: 10px;
  border-radius: 8px;
  margin-top: 6px;
}

/* === Components: Forms === */
input:not([type]),
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-sizing: border-box;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text-main);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.form-group,
.field {
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Checkbox */
input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
  cursor: pointer;
}

.checkbox-group {
  display: flex;
  align-items: center;
}

fieldset {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 24px;
  margin-bottom: 32px;
}

legend {
  font-weight: 700;
  color: var(--text-main);
  padding: 0 12px;
  font-size: 16px;
  margin-bottom: 16px;
}

.search-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-form input[type="text"] {
  flex: 1;
}

/* === Components: Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
}

table thead {
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  color: #fff;
}

table th,
table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

table tbody tr:nth-child(odd) {
  background: #fbfdff;
}

table tbody tr:hover {
  background: #f1f9ff;
}

/* === Components: Alerts === */
.alert,
.flash-success,
.flash-error,
.alert-success,
.alert-error {
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

/* Success Variant */
.flash-success,
.alert-success {
  background: linear-gradient(90deg, #ecfdf5, #bbf7d0);
  color: var(--success-text);
  border-color: var(--success-border);
  box-shadow: 0 6px 18px rgba(6, 95, 70, 0.06);
}

/* Error Variant */
.flash-error,
.alert-error {
  background: linear-gradient(90deg, var(--error-bg), #fee2e2);
  color: var(--error-text);
  border-color: var(--error-border);
  box-shadow: 0 6px 18px rgba(153, 27, 27, 0.06);
}

/* Global Flash Positioning */
body>.flash-success,
body>.flash-error {
  max-width: 1100px;
  margin: 84px auto 12px;
}

/* Inside Card Override */
.profile-card .flash-error,
.profile-card .flash-success {
  margin: 0 0 20px;
  max-width: none;
  width: auto;
  box-shadow: none;
  text-align: center;
  /* Ensure colors are applied even if specificity fights occur */
  background: linear-gradient(90deg, var(--error-bg), #fee2e2);
  color: var(--error-text);
  border: 1px solid var(--error-border);
}

.profile-card .flash-success {
  background: linear-gradient(90deg, #ecfdf5, #bbf7d0);
  color: var(--success-text);
  border-color: var(--success-border);
}

/* === Specific Page Styles === */
/* Daniel / Login */
.daniel .avatar {
  width: 88px;
  height: 88px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.daniel .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.daniel h1 {
  margin: 8px 0 6px;
  font-size: 1.2rem;
  text-align: center;
}

/* Baza Header */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* Utilities */
.back a {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.back a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

/* === Responsive === */
@media (max-width: 720px) {
  header {
    width: calc(100% - 20px);
    padding: 6px 10px;
  }

  main,
  .profile-card,
  .form-container {
    margin-left: 10px;
    margin-right: 10px;
    width: auto;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  body>.flash-success,
  body>.flash-error {
    margin: 72px 10px 12px;
  }
}

/* Utilities */
.hidden {
  display: none !important;
}

/* === Dashboard & Widgets === */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.widget-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 20px;
  border: 1px solid #e2e8f0;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.widget-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.deadline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.deadline-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.deadline-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border-color: #cbd5e1;
}

.deadline-date-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 50px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.deadline-day {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
}

.deadline-month {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
  margin-top: 2px;
}

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

.deadline-client {
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.deadline-task {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.deadline-tag {
  position: absolute;
  top: 0;
  right: 0;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  border-bottom-left-radius: 6px;
}

/* Urgency Colors */
.urgent .deadline-date-box { 
  border-color: #fca5a5; 
  color: #991b1b; 
  background: #fef2f2; 
}

.urgent .deadline-tag { 
  background: #ef4444; 
  color: white; 
}

.urgent:hover { 
  border-color: #fca5a5; 
}

.soon .deadline-date-box { 
  border-color: #fdba74; 
  color: #9a3412; 
  background: #fff7ed; 
}

.soon .deadline-tag { 
  background: #f97316; 
  color: white; 
}

.normal .deadline-date-box { 
  border-color: #cbd5e1; 
  color: #334155; 
}

.normal .deadline-tag { 
  display: none; 
}

/* ══════════════════════════════════════════════════════
   Session Timeout — badge (prawy górny róg)
   ══════════════════════════════════════════════════════ */
#st-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(15, 23, 42, 0.82);
    color: #94a3b8;
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 5px 12px 5px 9px;
    font-size: .78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    backdrop-filter: blur(6px);
    transition: background .3s, color .3s, border-color .3s;
    user-select: none;
    pointer-events: none;
}
.st-badge-icon {
    font-size: .9rem;
}
#st-badge-time {
    letter-spacing: .04em;
}
#st-badge.st-badge-warn {
    background: rgba(120, 30, 10, 0.88);
    border-color: #f59e0b;
    color: #fbbf24;
}

/* Online badge ─ ikona z licznikiem osób online */
#st-online-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(15, 23, 42, 0.82);
    color: #86efac;
    border: 1px solid #166534;
    border-radius: 20px;
    padding: 5px 11px 5px 8px;
    font-size: .78rem;
    font-weight: 700;
    backdrop-filter: blur(6px);
    text-decoration: none;
    transition: background .2s, border-color .2s;
    user-select: none;
    cursor: pointer;
}
#st-online-badge:hover {
    background: rgba(20, 83, 45, 0.85);
    border-color: #22c55e;
    color: #bbf7d0;
}
.st-online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(34,197,94,.3);
    animation: st-pulse 1.8s infinite;
}
@keyframes st-pulse {
    0%,100% { box-shadow: 0 0 0 2px rgba(34,197,94,.3); }
    50%      { box-shadow: 0 0 0 5px rgba(34,197,94,.07); }
}

/* ── Narożnik z odznakami sesji ── */
#st-corner {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 8000;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Inbox badge ─ ikona koperty */
#st-inbox-badge {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.82);
    color: #93c5fd;
    border: 1px solid #1e3a5f;
    border-radius: 20px;
    padding: 5px 11px;
    font-size: .78rem;
    font-weight: 600;
    backdrop-filter: blur(6px);
    text-decoration: none;
    transition: background .2s, border-color .2s, color .2s;
    user-select: none;
    cursor: pointer;
    white-space: nowrap;
}
#st-inbox-badge:hover {
    background: rgba(30, 58, 138, 0.85);
    border-color: #3b82f6;
    color: #bfdbfe;
}
#st-inbox-badge.has-unread {
    color: #fef08a;
    border-color: #ca8a04;
    background: rgba(120, 80, 0, 0.80);
    animation: st-inbox-pulse 2.4s infinite;
}
#st-inbox-badge.has-unread:hover {
    background: rgba(161, 98, 7, 0.90);
    border-color: #facc15;
}
@keyframes st-inbox-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(250,204,21,.0); }
    50%      { box-shadow: 0 0 0 4px rgba(250,204,21,.25); }
}
.st-inbox-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    min-width: 16px;
    height: 16px;
    font-size: .68rem;
    font-weight: 800;
    padding: 0 3px;
    line-height: 1;
    margin-left: 1px;
}
#st-inbox-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════
   Session Timeout — modal ostrzegawczy
   ══════════════════════════════════════════════════════ */
#st-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* domyślnie ukryty */
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
#st-overlay.st-overlay-visible {
    opacity: 1;
    pointer-events: auto;
}
#st-modal {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0,0,0,.35);
    padding: 40px 36px 32px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    transform: scale(.93);
    transition: transform .2s ease;
}
#st-overlay.st-overlay-visible #st-modal {
    transform: scale(1);
}
.st-modal-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}
.st-modal-title {
    margin: 0 0 4px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
}
.st-modal-counter {
    margin: 0 0 12px;
    font-size: 3.5rem;
    font-weight: 800;
    color: #f59e0b;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.st-modal-hint {
    margin: 0 0 28px;
    font-size: .88rem;
    color: #64748b;
    line-height: 1.5;
}
.st-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.st-btn {
    border: none;
    border-radius: 10px;
    padding: 11px 22px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
    min-width: 130px;
}
.st-btn-primary {
    background: #f59e0b;
    color: #1e293b;
}
.st-btn-primary:hover {
    background: #fbbf24;
}
.st-btn-ghost {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.st-btn-ghost:hover {
    background: #e2e8f0;
    color: #1e293b;
}
