/* ─── Reset ─────────────────────────────────────────── */

/*
  Josh's Custom CSS Reset
  https://www.joshwcomeau.com/css/custom-css-reset/
*/

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

*:not(dialog) {
  margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
}
h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

#root,
#__next {
  isolation: isolate;
}

/* ─── Base ──────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0); /* Deprecated but used for legacy support */
  border: 0;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

hr {
  width: calc(100% - 1rem);
  border: none;
  border-top: 1px solid #ddd;
  margin: 0.5rem;
}

.btn {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 0.4rem;
  background-color: #333;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}

.btn-feather-icon {
  width: 1.2rem;
  stroke-width: 2px;
}

/* ─── Layout helpers ────────────────────────────────── */

.main-content-wrapper {
  padding: 2rem;
}

.content-card-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

/* ─── Site header ───────────────────────────────────── */

.site-header {
  width: 100%;
  padding: 1.25rem 2rem;
  background: white;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.site-header a {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: #222;
}

.site-logo-container {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
}

.search {
  display: none;
}

@media screen and (min-width: 600px) {
  .search {
    display: inline-block;
  }
}

.search-form {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: baseline;
}

.searchbar {
  appearance: none;
  padding: 0.25rem;
  border-radius: 0.25rem 0 0 0.25rem;
  border: 2px solid #222;
  border-right: none;
}

.search-submit {
  padding: 0.25rem 0.5rem;
  border-radius: 0 0.25rem 0.25rem 0;
  border: 2px solid #222;
  border-left: 1px solid #222;
}

.search-filters {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  border: none;
  margin-left: 1rem;
}

.search-filters label {
  padding: 0.25rem 0.5rem;
  border-radius: 0.125rem;
  background: #fff;
  transition: all 200ms ease;
  cursor: pointer;
}

.search-filters input[type="radio"] {
  appearance: none;
}

.search-filters input[type="radio"]:checked + label {
  background: #e6e6e6;
  transition: all 200ms ease;
}

/* ─── Submenu ──────────────────────────────────── */

.layout-submenu {
  padding: 2rem 2rem 0 2rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.layout-submenu__details {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
}

.layout-submenu__btns {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.5rem;
}

/* ─── Account menu ──────────────────────────────────── */

.account-section {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.account-menu-toggle {
  padding: 0.5rem;
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}

.account-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 240px;
  padding: 1rem 0.5rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 0.25rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
}

.account-menu.hidden {
  display: none;
}

.account-menu-greeting {
  font-size: 1.2rem;
  font-weight: 600;
  padding: 0.5rem;
}

.account-menu-detail {
  padding: 0 0.5rem 0.5rem 0.5rem;
}

.account-menu__btn {
  text-align: left;
  width: 100%;
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0.125rem;
  transition: background 120ms ease-in;
}

.account-menu__btn:hover {
  background: #eee;
}

.account-menu__btn.inactive {
  color: #bbb;
}

/* ─── Folder menu ───────────────────────────────────── */

.folder-menu-section {
  position: relative;
  margin-left: 0.75rem;
}

.folder-menu-toggle {
  padding: 0.25rem 0.5rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.folder-menu-toggle:hover {
  background: #eee;
  border-color: #ddd;
}

.folder-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  min-width: 180px;
  padding: 0.5rem 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 0.25rem;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.folder-menu.hidden {
  display: none;
}

.folder-menu__item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  text-align: left;
  text-decoration: none;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0;
}

.folder-menu__item:hover {
  background: #eee;
}

.folder-menu__item--danger {
  color: #b91c1c;
}

/* ─── Auth panel (login / register forms) ───────────── */

.content-card-panel {
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.content-card-panel h2,
.content-card-panel .title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.field {
  margin-bottom: 1rem;
}

.content-card-panel label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus {
  border-color: #555;
}

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 6px;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.btn-primary {
  width: 100%;
  padding: 0.625rem;
  background: #222;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.5rem;
}

.btn-primary:hover {
  background: #444;
}

.auth-alt {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e5e5;
  text-align: center;
  font-size: 0.875rem;
  color: #666;
}

.auth-alt a {
  display: inline-block;
  margin-top: 0.625rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #222;
  text-decoration: none;
}

.auth-alt a:hover {
  background: #f5f5f5;
  border-color: #999;
}

.greeting {
  font-size: 1.6rem;
  font-weight: bold;
}

/* ─── View toggle ───────────────────────────────────── */

.view-toggle {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
}

.view-toggle__link {
  font-size: 0.8rem;
  padding: 0.25rem 0.625rem;
  border-radius: 0.25rem;
  text-decoration: none;
  color: #555;
  border: 1px solid transparent;
}

.view-toggle__link:hover {
  background: #e6e6e6;
}

.view-toggle__link--active {
  background: #e6e6e6;
  border-color: #ccc;
  color: #222;
  font-weight: 500;
}

.files,
.folders {
  margin: 0 auto 3rem auto;
}

.files ul,
.folders ul {
  padding: 0;
}

.files-heading,
.folders-heading {
  font-size: 1rem;
  margin-bottom: 2rem;
  font-weight: 600;
}

.files-grid,
.folders-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 2fr));
  gap: 1rem;
}

.files-grid li,
.folders-grid li {
  list-style-type: none;
}

@media screen and (min-width: 600px) {
  .files-grid,
  .folders-grid {
    grid-template-columns: repeat(auto-fill, minmax(10rem, 2fr));
  }
}

.file-elements,
.folder-elements {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

.img-wrapper {
  width: 4rem;
  aspect-ratio: 1 / 1;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.file-icon,
.folder-icon {
  width: auto;
  height: 100%;
}

.file-name,
.folder-name {
  font-size: 0.9rem;
  text-align: center;
  text-wrap: pretty;
  text-decoration: none;
  cursor: pointer;
}

/* ----- folder detail view ----- */

.folder-detail {
  padding: 2rem;
}

.folder-detail__header {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: baseline;
}

.folder-detail__title {
  font-size: 1.2rem;
  margin-right: 1.6rem;
  margin-bottom: 1rem;
}

.folder-detail__button {
  font-size: 0.8rem;
  color: inherit;
  display: inline-block;
  padding: 0.5rem;
  background: none;
  border: none;
  border-radius: 1rem;
  text-decoration: none;
  text-decoration: underline;
  cursor: pointer;
}

/* ----- file detail view ----- */

.file-detail-wrapper {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-start;
}

@media screen and (min-width: 600px) {
  .file-detail-wrapper {
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 2rem;
  }
}

.file-detail-wrapper img {
  padding: 1rem;
  background-color: #eee;
  border: 1px solid #e5e5e5;
  border-radius: 0.4rem;
}

.file-detail-wrapper ul {
  list-style-type: none;
  padding: 0;
}

.file-detail-wrapper li {
  display: grid;
  grid-template-columns: 80px calc(100% - 80px);
  margin-bottom: 0.25rem;
}

.file-detail-wrapper li:last-of-type {
  margin-bottom: 0;
}

.file-detail__btn-wrapper {
  margin: 2rem 0;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 0.5rem;
}

.file-detail__btn {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.4rem;
  background-color: #333;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}

.file-detail__btn.delete {
  color: #d0342c;
  background-color: rgba(208, 52, 44, 0.1);
}
