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

:root {
  --green: #2E7D32;
  --green-dark: #1B5E20;
  --green-darker: #144618;
  --green-light: #A5D6A7;
  --green-pale: #E8F5E9;
  --text: #2c2c2c;
  --muted: #6b6b6b;
  --bg: #f5f5f5;
  --card: #ffffff;
  --border: #ddd;
  --row-hover: #fafafa;
  --error-bg: #f8d7da;
  --error-bd: #f5c6cb;
  --error-fg: #721c24;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
}

a { color: var(--green-dark); }
a:hover { text-decoration: underline; }

/* ------------------------------ Navigation ------------------------------ */
.main-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 50px;
  background-color: var(--green);
  color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.nav-brand:hover { text-decoration: none; }

.nav-logo {
  height: 30px;
  width: auto;
  filter: brightness(0) invert(1); /* force white in case logo isn't pure white */
}

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

.nav-user {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}

.nav-logout {
  color: white;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  transition: background-color 0.15s;
}

.nav-logout:hover {
  background-color: var(--green-dark);
  text-decoration: none;
}

/* -------------------------------- Layout -------------------------------- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.container.loading {
  opacity: 0.55;
  transition: opacity 0.15s ease-in 0.1s; /* only show dim if load takes > 100ms */
  pointer-events: none;
}

.breadcrumb {
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--green-dark);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 6px; color: #aaa; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* --------------------------------- Card --------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background-color: #f9f9f9;
  gap: 12px;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  word-break: break-all;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

/* -------------------------------- Tables -------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.data-table th {
  background-color: #f9f9f9;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background-color: var(--row-hover); }

.data-table th.num,
.data-table td.num {
  text-align: right;
  white-space: nowrap;
  width: 100px;
  font-variant-numeric: tabular-nums;
}

.data-table th.actions,
.data-table td.actions {
  text-align: right;
  width: 110px;
  white-space: nowrap;
}

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

/* ------------------------- Entries (folder/file) ------------------------ */
.entry {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  word-break: break-all;
}

.entry-dir { color: var(--green-dark); font-weight: 500; }
.entry-dir:hover { text-decoration: underline; }
.entry-file { color: var(--text); }

.icon-folder, .icon-file {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.icon-folder {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232E7D32'><path d='M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z'/></svg>");
}

.icon-file {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23888'><path d='M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z'/></svg>");
}

/* -------------------------------- Buttons ------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  background-color: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn:hover {
  background-color: #f5f5f5;
  text-decoration: none;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-primary {
  background-color: var(--green);
  border-color: var(--green);
  color: white;
}

.btn-primary:hover {
  background-color: var(--green-dark);
  border-color: var(--green-dark);
  color: white;
}

.btn-cancel {
  background-color: white;
  border-color: #d33;
  color: #d33;
}

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

/* ---------------------------- Bottom dock ------------------------------ */
.download-dock {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  z-index: 1000;
  transition: transform 0.2s, opacity 0.2s;
}

.download-dock.hidden {
  display: none;
}

.dock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.dock-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dock-title strong {
  font-size: 14px;
  color: var(--text);
}

.dock-title .muted {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-progress {
  width: 100%;
  height: 8px;
  background-color: #ececec;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.dock-bar {
  height: 100%;
  width: 0%;
  background-color: var(--green);
  transition: width 0.3s ease-out;
  border-radius: 4px;
}

.dock-bar.indeterminate {
  width: 35% !important;
  animation: indeterminate 1.4s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(280%); }
}

.dock-status {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-status.error { color: #d33; }
.dock-status.success { color: var(--green-dark); }

/* --------------------------------- Login -------------------------------- */
.login-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.login-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.login-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background-color: #f9f9f9;
  text-align: center;
}

.login-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 5px 0;
}

.login-header p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.login-body-inner {
  padding: 30px 20px;
  text-align: center;
}

.login-info {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 25px;
}

.btn-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  background-color: #2f2f2f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s;
}

.btn-microsoft:hover {
  background-color: #1a1a1a;
  text-decoration: none;
  color: white;
}

.btn-microsoft svg {
  width: 20px;
  height: 20px;
}

.login-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background-color: #f9f9f9;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.error-message {
  background-color: var(--error-bg);
  border: 1px solid var(--error-bd);
  color: var(--error-fg);
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 18px;
  font-size: 13px;
  text-align: left;
}

.domain-badge {
  display: inline-block;
  padding: 2px 8px;
  background-color: var(--green-pale);
  color: var(--green-darker);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

/* --------------------------------- Error -------------------------------- */
.error-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 30px;
  text-align: center;
  max-width: 600px;
  margin: 40px auto;
}

.error-card h1 {
  font-size: 20px;
  margin-bottom: 10px;
}

.error-card p {
  color: var(--muted);
  margin-bottom: 10px;
}
