/* ── Reset / base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f5f5;
  --surface:   #ffffff;
  --border:    #e0e0e0;
  --accent:    #1a73e8;
  --accent-dk: #1558b0;
  --danger:    #d93025;
  --danger-dk: #b31412;
  --success:   #188038;
  --text:      #202124;
  --muted:     #5f6368;
  --radius:    6px;
  --shadow:    0 1px 4px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────────── */
header {
  background: var(--accent);
  color: #fff;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  flex-shrink: 0;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: .02em;
}

#header-actions { display: flex; gap: .75rem; align-items: center; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  padding: .45rem 1rem;
  transition: background .15s, opacity .15s;
}

button:disabled { opacity: .5; cursor: not-allowed; }

/* Primary (default) */
button:not(.secondary):not(.danger):not(.small) {
  background: var(--accent);
  color: #fff;
}
button:not(.secondary):not(.danger):not(.small):hover:not(:disabled) {
  background: var(--accent-dk);
}

/* Secondary */
button.secondary { background: rgba(255,255,255,.15); color: #fff; }
button.secondary:hover:not(:disabled) { background: rgba(255,255,255,.25); }

/* Danger */
button.danger { background: var(--danger); color: #fff; }
button.danger:hover:not(:disabled) { background: var(--danger-dk); }

/* Small (inline file-list buttons) */
button.small {
  padding: .2rem .5rem;
  font-size: .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
button.small:hover:not(:disabled) { background: var(--bg); }
button.small.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
button.small.danger:hover:not(:disabled) { background: var(--danger-dk); }

/* ── Banner ───────────────────────────────────────────────────────────── */
#banner {
  padding: .65rem 1.5rem;
  font-size: .9rem;
}
#banner.error   { background: #fce8e6; color: var(--danger); }
#banner.warning { background: #fef7e0; color: #7a5800; }
#banner.success { background: #e6f4ea; color: var(--success); }

/* ── Main ─────────────────────────────────────────────────────────────── */
main { flex: 1; padding: 1.5rem; max-width: 960px; width: 100%; margin: 0 auto; }

/* ── Landing ──────────────────────────────────────────────────────────── */
#landing {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 4rem;
}

.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
}

.landing-icon { font-size: 3rem; margin-bottom: 1rem; }
.landing-card h2 { font-size: 1.2rem; margin-bottom: .5rem; }
.landing-card p  { color: var(--muted); font-size: .95rem; line-height: 1.5; }

.landing-notes {
  list-style: none;
  margin-top: 1.25rem;
  text-align: left;
  font-size: .85rem;
  color: var(--muted);
}
.landing-notes li { padding: .3rem 0; }
.landing-notes li::before { content: '•'; margin-right: .5rem; }

/* ── Device info bar ──────────────────────────────────────────────────── */
#device-info {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}

#device-name  { font-weight: 600; font-size: 1.05rem; }
#device-model { color: var(--muted); font-size: .9rem; }

.badge {
  background: #e8f0fe;
  color: var(--accent-dk);
  border-radius: 99px;
  padding: .15rem .6rem;
  font-size: .8rem;
  font-weight: 500;
}

/* ── Storage bar ──────────────────────────────────────────────────────── */
#storage-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  font-size: .9rem;
}

#storage-select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem .6rem;
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex: 1;
  max-width: 420px;
}

/* ── File browser ─────────────────────────────────────────────────────── */
#file-browser {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Toolbar */
#browser-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  gap: 1rem;
}

/* Breadcrumb */
#breadcrumb { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; font-size: .9rem; }

.crumb {
  color: var(--muted);
  padding: .1rem .25rem;
  border-radius: 3px;
}
.crumb-link {
  color: var(--accent);
  cursor: pointer;
}
.crumb-link:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); margin: 0 .1rem; }

/* Browser actions */
#browser-actions { display: flex; gap: .5rem; flex-shrink: 0; }
#btn-upload {
  padding: .35rem .85rem;
  font-size: .85rem;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
#btn-upload:hover { background: #e8f0fe; }

/* File list container */
#file-list-container {
  overflow-y: auto;
  max-height: calc(100vh - 320px);
  min-height: 120px;
}

#file-list {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

#file-list thead th {
  position: sticky;
  top: 0;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  padding: .55rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  z-index: 1;
}

#file-list tbody tr { border-bottom: 1px solid var(--border); }
#file-list tbody tr:last-child { border-bottom: none; }
#file-list tbody tr:hover { background: #f8f9fa; }

#file-list td { padding: .55rem 1rem; vertical-align: middle; }

.col-name { width: 50%; }
.col-size { width: 12%; white-space: nowrap; color: var(--muted); }
.col-date { width: 18%; white-space: nowrap; color: var(--muted); }
.col-actions { width: 20%; text-align: right; white-space: nowrap; }

.col-name.folder { cursor: pointer; }
.col-name.folder:hover .file-name { text-decoration: underline; color: var(--accent); }
.col-name.folder .file-name { font-weight: 500; }

.file-icon { margin-right: .5rem; }

/* Space the action buttons without turning the <td> into a flex container,
   which would drop it out of table layout and misalign the column. */
td.col-actions > * + * { margin-left: .4rem; }

/* Empty / loading */
#file-list-empty, #file-list-loading {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}

/* ── Overlays (transfer + confirm) ───────────────────────────────────── */
#transfer-overlay, #confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#transfer-box, #confirm-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  padding: 2rem 2.5rem;
  min-width: 320px;
  max-width: 480px;
  width: 90%;
  text-align: center;
}

#transfer-label { font-weight: 600; margin-bottom: 1rem; }
#transfer-detail { font-size: .85rem; margin-top: .6rem; color: var(--muted); }

#progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .2s ease;
  width: 0%;
}

#confirm-message { margin-bottom: 1.5rem; font-size: .95rem; line-height: 1.5; }
#confirm-buttons { display: flex; gap: .75rem; justify-content: center; }

/* ── Utilities ────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.muted   { color: var(--muted); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  main { padding: 1rem; }
  .col-date { display: none; }
  .col-size { display: none; }
  #file-list-container { max-height: calc(100vh - 260px); }
}
