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

:root {
  --yt-bg: #0f0f0f;
  --yt-surface: #1a1a1a;
  --yt-surface-2: #272727;
  --yt-border: rgba(255,255,255,0.1);
  --yt-text: #f1f1f1;
  --yt-text-secondary: #aaaaaa;
  --yt-red: #ff0004;
  --yt-red-hover: #cc0000;
  --yt-blue: #3ea6ff;
  --yt-green: #2ba640;
  --yt-error: #ff4e45;
  --yt-error-bg: rgba(255,78,69,0.1);
  --yt-radius: 4px;
}

html, body {
  height: 100%;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--yt-bg);
  color: var(--yt-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--yt-surface-2); border-radius: 3px; }

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------ AUTH CARD ------ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: var(--yt-surface);
  border: 1px solid var(--yt-border);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.auth-card > p {
  color: var(--yt-text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

/* ------ TEXT FIELDS ------ */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--yt-text-secondary);
  margin-bottom: 0.25rem;
}

.form-group input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  height: 36px;
  background: var(--yt-surface-2);
  border: 1px solid var(--yt-border);
  border-radius: var(--yt-radius);
  color: var(--yt-text);
  font-size: 0.9375rem;
  outline: none;
  transition: border 0.15s;
}

.form-group input:focus {
  border-color: var(--yt-blue);
}

/* ------ BUTTONS ------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
  height: 36px;
  border: none;
  border-radius: 2px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}

.btn:active {
  opacity: 0.8;
}

.btn-primary {
  background: var(--yt-blue);
  color: #fff;
}

.btn-primary:hover {
  background: #5ab0ff;
}

.btn-primary:disabled {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.3);
  cursor: not-allowed;
  opacity: 1;
}

.btn-danger {
  background: transparent;
  color: var(--yt-text);
  border: 1px solid var(--yt-border);
}

.btn-danger:hover {
  background: rgba(255,255,255,0.05);
}

.btn-sm {
  background: transparent;
  color: var(--yt-text-secondary);
  width: auto;
  height: 28px;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  border-radius: 2px;
}

.btn-sm:hover {
  background: rgba(255,255,255,0.05);
  color: var(--yt-text);
}

/* Outline buttons (settings) */
.btn-outline {
  background: transparent;
  color: var(--yt-text);
  width: auto;
  height: 32px;
  padding: 0 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--yt-border);
  border-radius: 2px;
}

.btn-outline:hover {
  background: rgba(255,255,255,0.05);
}

.btn-outline-danger {
  background: transparent;
  color: var(--yt-text-secondary);
  width: auto;
  height: 32px;
  padding: 0 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--yt-border);
  border-radius: 2px;
}

.btn-outline-danger:hover {
  background: rgba(255,255,255,0.05);
  color: var(--yt-error);
}

/* ------ AUTH LINK ------ */
.auth-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--yt-text-secondary);
}

.auth-link a {
  color: var(--yt-blue);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* ------ ERROR ALERT ------ */
.error-msg {
  background: var(--yt-error-bg);
  border: 1px solid rgba(255,78,69,0.3);
  border-radius: var(--yt-radius);
  color: var(--yt-error);
  padding: 0.625rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: none;
}

.error-msg.show {
  display: block;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ------ TOP APP BAR ------ */
.dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.nav {
  background: var(--yt-bg);
  border-bottom: 1px solid var(--yt-border);
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav h2 {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--yt-text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-right span {
  color: var(--yt-text-secondary);
  font-size: 0.875rem;
}

.main {
  flex: 1;
  padding: 1.5rem 1rem;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

/* ------ TABS ------ */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--yt-border);
}

.tab {
  padding: 0.625rem 2rem;
  background: transparent;
  border: none;
  color: var(--yt-text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: 0;
  transition: color 0.15s;
  position: relative;
}

.tab::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--yt-text);
  transform: scaleX(0);
  transition: transform 0.15s;
}

.tab.active {
  color: var(--yt-text);
}

.tab.active::after {
  transform: scaleX(1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ------ CARDS (Upload section, Settings section) ------ */
.upload-section,
.settings-section {
  background: var(--yt-surface);
  border: 1px solid var(--yt-border);
  border-radius: 8px;
  padding: 1rem 1.5rem 1.25rem;
  margin-bottom: 1rem;
}

.upload-section h3,
.settings-section h3 {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
  margin-bottom: 1rem;
}

/* ------ DROP ZONE ------ */
.drop-zone {
  border: 2px dashed var(--yt-border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 1rem;
}

.drop-zone:hover {
  border-color: var(--yt-blue);
  background: rgba(62, 166, 255, 0.05);
}

.drop-zone.dragover {
  border-color: var(--yt-blue);
  background: rgba(62, 166, 255, 0.08);
}

.drop-zone p {
  color: var(--yt-text-secondary);
}

.drop-zone .file-count {
  color: var(--yt-text);
  font-weight: 500;
  display: none;
}

.drop-zone.has-file .file-count { display: block; }
.drop-zone.has-file .drop-hint { display: none; }

/* ------ TEXT FIELDS (upload-meta) ------ */
.upload-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.upload-meta > div {
  display: flex;
  flex-direction: column;
}

.video-card-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--yt-text-secondary);
  margin-bottom: 0.25rem;
}

.upload-meta input,
.upload-meta textarea,
.upload-meta select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  height: 36px;
  background: var(--yt-surface-2);
  border: 1px solid var(--yt-border);
  border-radius: var(--yt-radius);
  color: var(--yt-text);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border 0.15s;
}

.upload-meta textarea {
  height: auto;
  min-height: 36px;
  resize: vertical;
}

.upload-meta select {
  cursor: pointer;
}

.upload-meta input:focus,
.upload-meta textarea:focus,
.upload-meta select:focus {
  border-color: var(--yt-blue);
}

.upload-meta input:disabled,
.upload-meta textarea:disabled,
.upload-meta select:disabled {
  border-color: var(--yt-border);
  color: var(--yt-text-secondary);
  cursor: not-allowed;
  opacity: 0.5;
}

/* ------ VIDEO CARDS (pre-upload) ------ */
.video-card {
  background: var(--yt-surface);
  border: 1px solid var(--yt-border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.video-card-body {
  display: flex;
  gap: 0.75rem;
}

.video-thumb {
  flex-shrink: 0;
  width: 160px;
  height: 90px;
  border-radius: var(--yt-radius);
  overflow: hidden;
  background: var(--yt-surface-2);
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--yt-text-secondary);
}

.video-thumb-placeholder svg {
  width: 24px;
  height: 24px;
  opacity: 0.5;
}

.video-card-fields {
  flex: 1;
  min-width: 0;
}

.video-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.video-card-filename {
  font-weight: 500;
  font-size: 0.875rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-card-status {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--yt-radius);
  background: var(--yt-surface-2);
  font-weight: 500;
  flex-shrink: 0;
  line-height: 1.4;
}

.video-card-status.uploading {
  background: rgba(62, 166, 255, 0.15);
  color: var(--yt-blue);
}

.video-card-status.done {
  background: rgba(43, 166, 64, 0.15);
  color: var(--yt-green);
}

.video-card-status.failed {
  background: rgba(255, 78, 69, 0.15);
  color: var(--yt-error);
}

/* ------ PLATFORM CARDS ------ */
.platform-grid {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.platform-card {
  flex: 1;
  min-width: 100px;
  background: transparent;
  border: 1px solid var(--yt-border);
  border-radius: var(--yt-radius);
  padding: 0.625rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.platform-card:hover {
  background: rgba(255,255,255,0.05);
}

.platform-card.selected {
  background: rgba(255,0,4,0.1);
  border-color: var(--yt-red);
}

.platform-card .platform-name {
  font-size: 0.8125rem;
  font-weight: 500;
}

.platform-card .platform-status {
  font-size: 0.6875rem;
  color: var(--yt-text-secondary);
  margin-top: 0.125rem;
}

.platform-card .platform-status.connected {
  color: var(--yt-green);
}

/* ------ UPLOAD LIST (YouTube Studio style rows) ------ */
.uploads-list {
  display: flex;
  flex-direction: column;
}

.upload-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--yt-border);
}

.upload-item:last-child {
  border-bottom: none;
}

.upload-thumb {
  flex-shrink: 0;
  width: 160px;
  height: 90px;
  border-radius: var(--yt-radius);
  overflow: hidden;
  background: var(--yt-surface-2);
  position: relative;
}

.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.upload-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--yt-text-secondary);
}

.upload-thumb-placeholder svg {
  width: 24px;
  height: 24px;
  opacity: 0.5;
}

.upload-item-fields {
  flex: 1;
  min-width: 0;
}

.upload-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.125rem;
}

.upload-item-title {
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item-meta {
  font-size: 0.8125rem;
  color: var(--yt-text-secondary);
  margin-bottom: 0.375rem;
}

.upload-targets {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.target-badge {
  font-size: 0.6875rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--yt-radius);
  background: var(--yt-surface-2);
  font-weight: 500;
  line-height: 1.4;
  color: var(--yt-text-secondary);
}

.target-badge.done {
  background: rgba(43, 166, 64, 0.15);
  color: var(--yt-green);
}

.target-badge.failed {
  background: rgba(255, 78, 69, 0.15);
  color: var(--yt-error);
}

.target-badge.uploading {
  background: rgba(62, 166, 255, 0.15);
  color: var(--yt-blue);
}

/* ------ PROGRESS ------ */
.progress-bar {
  height: 3px;
  background: var(--yt-surface-2);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--yt-blue);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ------ SETTINGS LIST ------ */
.platform-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--yt-border);
}

.platform-row:last-child {
  border-bottom: none;
}

.platform-row span {
  font-size: 0.9375rem;
  font-weight: 500;
}

/* ------ EMPTY STATE ------ */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--yt-text-secondary);
}

.empty-state p {
  font-size: 0.875rem;
}
