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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
  background: #f5f6f8;
}

[hidden] {
  display: none !important;
}

#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #dbe4f1;
  border-top-color: #447dd1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#not-authenticated {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.card {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.card h1 {
  font-size: 1.25rem;
  margin: 1rem 0 0.5rem;
}

.card p {
  color: #666;
  margin-bottom: 1.25rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: #333;
  background: #fff;
  border: 1px solid #c5c5c5;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.button:hover {
  background: #f0f2f5;
  border-color: #a0a0a0;
}

.button.primary {
  color: #fff;
  background: #447dd1;
  border-color: #447dd1;
}

.button.primary:hover {
  background: #3566b0;
  border-color: #3566b0;
}

.button.small {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.button.danger {
  color: #b42318;
  border-color: #fca5a5;
  background: #fef2f2;
}

.button.danger:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e1e4e8;
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  color: #1f2937;
}

.brand img {
  height: 28px;
  width: auto;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.content {
  padding: 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #fef2f2;
  color: #b42318;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.error-banner .close {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: #b42318;
  cursor: pointer;
  line-height: 1;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.file-table thead {
  background: #eef2f8;
}

.file-table th,
.file-table td {
  padding: 0.85rem 1rem;
  text-align: left;
}

.file-table th {
  font-weight: 600;
  font-size: 0.85rem;
  color: #4b5563;
  position: sticky;
  top: 0;
}

.file-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.file-table tbody tr:hover {
  background: #f0f5fb;
}

.col-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0; /* let flex/table handle it */
}

.file-icon {
  vertical-align: middle;
  margin-right: 0.5rem;
}

.col-modified {
  width: 180px;
  color: #6b7280;
}

.col-actions {
  width: 180px;
  text-align: right !important;
  white-space: nowrap;
}

.col-actions .button {
  margin-left: 0.35rem;
}

.empty {
  text-align: center;
  color: #6b7280;
  padding: 2rem;
}

@media (max-width: 640px) {
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
  }

  .file-table th,
  .file-table td {
    padding: 0.65rem 0.5rem;
  }

  .col-modified {
    width: auto;
  }
}

/* ─── Editor panel ─────────────────────────────────────────────────────────── */

#editor-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#editor-panel[hidden] {
  display: none !important;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border-bottom: 1px solid #e1e4e8;
  flex-shrink: 0;
}

.editor-title {
  font-weight: 600;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.editor-container iframe {
  border: none;
  width: 100%;
  height: 100%;
}

.editor-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #6b7280;
}

.editor-loading .spinner {
  margin-bottom: 1rem;
}
