/* GEFMO Thumbnail Studio v2.0 — Ciemny motyw newsowy */

:root {
  --bg-primary: #09090b;
  --bg-secondary: #111113;
  --bg-card: #18181b;
  --bg-input: #18181b;
  --bg-hover: #1f1f23;
  --accent: #e63946;
  --accent-hover: #c1121f;
  --accent-subtle: rgba(230, 57, 70, 0.1);
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-faint: #52525b;
  --text-muted: #3f3f46;
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(230, 57, 70, 0.4);
  --font-display: 'Bebas Neue', Impact, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', ui-monospace, monospace;
  --radius: 8px;
  --radius-lg: 10px;
}

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

body {
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 20px;
  color: #fff;
  font-weight: 700;
}

.header-title {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
}

.header-badge {
  font-size: 11px;
  color: var(--text-faint);
  background: rgba(255,255,255,0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-size {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== MAIN LAYOUT ===== */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 360px;
  min-width: 360px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
}

/* Zakładki */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 10;
}

.tab {
  flex: 1;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-faint);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* Tab content */
.tab-content {
  display: none;
  padding: 20px;
  flex-direction: column;
  gap: 4px;
}

.tab-content.active {
  display: flex;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-label-small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--border-focus);
}

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

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2352525b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-input-small {
  width: 80px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.form-input-small:focus {
  border-color: var(--border-focus);
}

.form-range {
  width: 100%;
  height: 4px;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  margin-top: 4px;
}

.form-range::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.form-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.slider-value {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* Row layout */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.custom-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.size-x {
  color: var(--text-faint);
  font-size: 13px;
}

/* Buttons */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font-body);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-outline:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-outline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-secondary);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

/* Input with button */
.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn .form-input {
  flex: 1;
}

/* ===== COLOR SWATCHES ===== */
.color-swatches {
  display: flex;
  gap: 8px;
}

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}

.swatch:hover {
  border-color: var(--text-faint);
}

.swatch.active {
  border-color: var(--accent);
}

/* ===== POSITION BUTTONS ===== */
.position-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.pos-btn {
  padding: 8px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.pos-btn:hover {
  border-color: var(--border-hover);
}

.pos-btn.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== CHECKBOX ===== */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 8px;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* ===== TEMPLATES GRID ===== */
.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.template-btn {
  height: 56px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  padding: 6px 10px;
  transition: border-color 0.15s;
}

.template-btn span {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-body);
}

.template-btn:hover {
  border-color: var(--border-hover);
}

.template-btn.active {
  border-color: var(--accent);
}

/* ===== MODEL CARDS ===== */
.model-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.model-card {
  padding: 12px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.model-card strong {
  display: block;
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.model-card span {
  font-size: 11px;
  color: var(--text-faint);
}

.model-card:hover {
  border-color: var(--border-hover);
}

.model-card.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

/* ===== DROP ZONE ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.drop-zone span {
  font-size: 13px;
  color: var(--text-faint);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
}

/* ===== SEPARATOR ===== */
.separator {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ===== INFO BOX ===== */
.info-box {
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}

/* ===== HISTORY GRID ===== */
.history-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.history-item {
  aspect-ratio: 16/9;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== CANVAS AREA ===== */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 16px;
  background: var(--bg-primary);
  overflow: auto;
}

.canvas-wrapper {
  max-width: 100%;
  max-height: calc(100vh - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#previewCanvas {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

/* ===== STATUS BAR ===== */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 800px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.status-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green {
  background: #4ade80;
}

.status-dot.yellow {
  background: #fde047;
  animation: pulse 1s ease-in-out infinite;
}

.status-dot.red {
  background: #ef4444;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.status-right {
  display: flex;
  gap: 8px;
}

/* ===== FOOTER ===== */
.app-footer {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: 700px;
  max-width: 90vw;
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.modal-body h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 10px;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  margin: 8px 0;
}

.modal-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.modal-body p code {
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-body ul {
  padding-left: 20px;
}

.modal-body li {
  margin-bottom: 6px;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.docs-table th,
.docs-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.docs-table th {
  color: var(--text-faint);
  font-weight: 500;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 300;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== RESPONSIVE (tablet) ===== */
@media (max-width: 1024px) {
  .sidebar {
    width: 320px;
    min-width: 320px;
  }

  .canvas-area {
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .app-main {
    flex-direction: column;
    overflow-y: auto;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .canvas-area {
    min-height: 400px;
  }

  .header-size {
    display: none;
  }
}
