/* Printhive — Workshop Dark theme */
:root {
  --bg: #15171c;
  --surface: #1e2128;
  --surface-2: #262a32;
  --surface-3: #2d323b;
  --border: #2f343d;
  --border-strong: #3b424d;
  --text: #e7e9ee;
  --text-muted: #9aa0ab;
  --text-dim: #6b7280;
  --accent: #f0972a;
  --accent-hover: #ffab45;
  --accent-soft: rgba(240, 151, 42, 0.14);
  --accent-text: #1a1205;
  --danger: #e35d5b;
  --danger-soft: rgba(227, 93, 91, 0.14);
  --success: #4cc38a;
  --radius: 10px;
  --radius-sm: 7px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- header ---- */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(21, 23, 28, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 11px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.brand .logo { width: 26px; height: 26px; color: var(--accent); }
.brand .accent { color: var(--accent); }

.header-actions { display: flex; gap: 10px; }

/* ---- buttons ---- */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn-sm { font-size: 12px; padding: 6px 12px; align-self: flex-start; }
.download-all { display: inline-block; text-decoration: none; margin-bottom: 10px; }
.download-all:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--text-muted); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }

/* ---- layout ---- */
.main-content { flex: 1; display: grid; grid-template-columns: 260px 1fr; gap: 24px; padding: 24px 28px; max-width: 1500px; width: 100%; margin: 0 auto; }

.sidebar { display: flex; flex-direction: column; gap: 22px; }
.sidebar-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.sidebar-section h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 12px; }

.projects-list { display: flex; flex-direction: column; gap: 2px; }
.project-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); font-size: 14px; transition: background 0.12s, color 0.12s;
}
.project-item:hover { background: var(--surface-2); color: var(--text); }
.project-item.active { background: var(--accent-soft); color: var(--accent); }
.project-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-meta { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.collection-action { opacity: 0; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 3px; font-family: inherit; transition: color 0.12s, opacity 0.12s; }
.project-item:hover .collection-action { opacity: 1; }
.collection-action:hover { color: var(--text); }
.collection-delete:hover { color: var(--danger); }
.project-item .count { font-family: var(--mono); font-size: 12px; background: var(--surface-3); color: var(--text-muted); padding: 1px 8px; border-radius: 10px; }
.project-item.active .count { background: var(--accent); color: var(--accent-text); }

.tags-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12px; padding: 4px 10px; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
  transition: all 0.12s;
}
.tag:hover { border-color: var(--border-strong); color: var(--text); }
.tag.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ---- form fields ---- */
.search-input, input[type="text"], input[type="url"], input[type="password"], input[type="file"], textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="file"] { padding: 8px; color: var(--text-muted); }
textarea { resize: vertical; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 7px; }

/* ---- content ---- */
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.content-header h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.view-options { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.view-btn { font-family: inherit; font-size: 13px; padding: 5px 14px; border: none; background: transparent; color: var(--text-muted); border-radius: 5px; cursor: pointer; }
.view-btn.active { background: var(--surface-3); color: var(--text); }

/* ---- model grid ---- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.file-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }

.file-thumbnail {
  width: 100%; height: 185px;
  background: radial-gradient(circle at 50% 40%, #232730 0%, #14161a 100%);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 46px;
  border-bottom: 1px solid var(--border);
}
.file-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

.file-info { padding: 14px 16px; }
.file-name { font-size: 15px; font-weight: 600; margin-bottom: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-badge { display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 10px; margin-bottom: 8px; }
.com-badge { display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 10px; margin: 0 0 8px 6px; }
.com-badge.ok { background: rgba(76, 195, 138, 0.16); color: var(--success); }
.com-badge.no { background: var(--danger-soft); color: var(--danger); }

.lic-badge { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 10px; margin-left: 6px; }
.lic-badge.ok { background: rgba(76, 195, 138, 0.16); color: var(--success); }
.lic-badge.no { background: var(--danger-soft); color: var(--danger); }
.lic-badge.unknown { background: var(--surface-3); color: var(--text-muted); }
.lic-note { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.file-description { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.file-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.file-tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); color: var(--text-muted); }
.file-meta { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

/* list view */
.file-grid.list-view { grid-template-columns: 1fr; }
.file-grid.list-view .file-card { display: flex; align-items: stretch; }
.file-grid.list-view .file-thumbnail { width: 130px; height: auto; min-height: 90px; flex-shrink: 0; border-bottom: none; border-right: 1px solid var(--border); font-size: 30px; }
.file-grid.list-view .file-info { flex: 1; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: var(--text-dim); }
.empty-state h3 { font-size: 18px; color: var(--text-muted); margin-bottom: 8px; }

/* ---- modals ---- */
.modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 9, 12, 0.7); backdrop-filter: blur(3px);
  align-items: flex-start; justify-content: center; padding: 60px 20px; overflow-y: auto;
}
.modal.active { display: flex; }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 520px; }
.modal-content.large { max-width: 960px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.close-btn { background: none; border: none; color: var(--text-dim); font-size: 26px; line-height: 1; cursor: pointer; transition: color 0.12s; }
.close-btn:hover { color: var(--text); }
.modal-body { padding: 22px; }
.form-group { margin-bottom: 18px; }
.print-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---- model detail ---- */
.file-detail-content { display: grid; grid-template-columns: 1.1fr 1fr; gap: 26px; }
.file-detail-preview { display: flex; flex-direction: column; gap: 10px; }
.model-viewer { width: 100%; height: 380px; background: radial-gradient(circle at 50% 40%, #232730 0%, #131519 100%); border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.model-viewer canvas { display: block; border-radius: var(--radius); }
.viewer-msg { color: var(--text-dim); font-size: 14px; padding: 20px; text-align: center; }
.viewer-fallback { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px; }
.viewer-fallback img { max-width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--radius-sm); }
.viewer-fallback span { color: var(--text-dim); font-size: 12px; text-align: center; }

.file-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.file-tab { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); padding: 5px 11px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; font-family: inherit; }
.file-tab:hover { color: var(--text); }
.file-tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.info-section { margin-bottom: 22px; }
.info-section:last-of-type { margin-bottom: 0; }
.info-section h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 9px; }
.info-section p, .info-section div { color: var(--text); font-size: 14px; line-height: 1.6; }
.info-section .tag { cursor: default; }

.file-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-muted); }
.file-row:last-child { border-bottom: none; }
.file-row em { color: var(--text-dim); font-style: normal; font-family: var(--mono); font-size: 12px; }

/* ---- import / settings ---- */
.import-status { margin-top: 14px; color: var(--text-muted); font-size: 14px; min-height: 20px; }
.form-hint { font-size: 12px; color: var(--text-dim); margin-top: 7px; line-height: 1.5; }
.form-hint-inline { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.settings-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 14px; }
.setting-status.is-set { color: var(--success); font-weight: 500; }
.setting-status.is-unset { color: var(--danger); font-weight: 500; }
.btn-link { background: none; border: none; color: var(--danger); padding: 6px 0 0; font-size: 13px; cursor: pointer; font-family: inherit; }
.btn-link:hover { text-decoration: underline; }

@media (max-width: 860px) {
  .main-content { grid-template-columns: 1fr; }
  .file-detail-content { grid-template-columns: 1fr; }
}

/* ---- auth screen ---- */
.auth-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px;
}
.auth-brand { justify-content: center; font-size: 24px; margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.auth-form input { width: 100%; }
.auth-form .btn-primary { margin-top: 4px; }
.auth-form .btn-link { color: var(--text-muted); align-self: center; }
.auth-form .btn-link:hover { color: var(--accent); }
.auth-error { margin-top: 14px; color: var(--text-muted); font-size: 13px; text-align: center; min-height: 18px; }
