/* CSS RESET STARTS HERE */

/* 1. Use a more-intuitive box-sizing model */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 2. Remove default margin */
*:not(dialog) {
  margin: 0;
}

/* 3. Enable keyword animations */
@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  /* 4. Increase line-height */
  line-height: 1.5;
  /* 5. Improve text rendering */
  -webkit-font-smoothing: antialiased;
}

/* 6. Improve media defaults */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* 7. Inherit fonts for form controls */
input,
button,
textarea,
select {
  font: inherit;
}

/* 8. Avoid text overflows */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

/* 9. Improve line wrapping */
p {
  text-wrap: pretty;
}

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

/*
  10. Create a root stacking context
*/
#root,
#__next {
  isolation: isolate;
}

/* CSS RESET ENDS HERE */

/* APP STYLES START HERE */

:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef2f7;
  --border: #d6dde6;
  --text: #1d2833;
  --muted: #5f6972;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --secondary: #64748b;
  --danger: #dc2626;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --error-bg: rgba(254, 226, 226, 0.75);
  --gradient: radial-gradient(circle at top, rgba(37, 99, 235, 0.12), transparent 35%), linear-gradient(180deg, #fbfcff 0%, #d2dbee 100%);
}

[data-theme='dark'] {
  --bg: #020617;
  --surface: #0f172a;
  --surface-soft: #192133;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --secondary: #94a3b8;
  --danger: #f87171;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --error-bg: rgba(248, 113, 113, 0.16);
  --gradient: radial-gradient(circle at top, rgba(96, 165, 250, 0.12), transparent 35%), linear-gradient(180deg, #020617 0%, #0f172a 100%);
}

html {
  min-height: 100%;
  background-color: var(--bg);
}

body.app-body {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  color: var(--text);
  background: var(--gradient);
}

.home-header,
.page-header,
main,
footer,
section {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.home-header,
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.5rem 0.5rem;
}

.home-header,
.index-section {
  a {
    text-decoration: none;

    .home-title,
    .index-title {
      display: flex;
      justify-content: center;
      align-items: center;
      text-align: center;
      padding: 0 0.5rem;
      border: 1px solid var(--primary);
      border-radius: 0 1rem 0.5rem 1rem;
      color: var(--primary);
      background-color: var(--surface-soft);
      font-size: clamp(1.6rem, 2.5vw, 2.8rem);
      transform: skewX(-24deg);

      img {
        display: inline;
      }
    }
  }

  .theme-toggle {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
}

.index-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;

  .index-subtitle {
    font-size: 1.2rem;
    font-style: italic;
    text-align: center;
  }
}

.page-header {
  .page-title {
    flex: 1;
    text-align: center;
  }
}

.section-title {
  margin-bottom: 0.8rem;
  font-size: 1.25rem;
  text-align: center;
}

.section-note,
.share-note,
.folder-meta,
.error-message,
.confirm-message {
  margin: 0.5rem 0;
  color: var(--muted);
  text-align: center;
}

.home-page,
.dashboard-page,
.auth-page,
.folder-page,
.file-details-page,
.shared-folder-page,
.error-page,
.confirm-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding-bottom: 3rem;
}

.hero-section,
.dashboard-section,
.upload-section,
.share-section,
.share-list-section,
.folder-files-section,
.file-details-section,
.confirm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1.5rem;

  .list-heading {
    margin-bottom: 0.25rem;
  }
}

.file-details-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.form-row {
  display: grid;
  gap: 0.5rem;
}

.form-input,
.form-select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--text);
}

.form-input:focus,
.form-select:focus,
button:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.auth-form,
.folder-form,
.upload-form,
.share-form,
.confirm-form {
  display: grid;
  gap: 0.8rem;
}

.progress-container {
  background-color: var(--surface-soft);
  border-radius: 0.5rem;
  height: 1.5rem;
  overflow: hidden;

  .progress-bar {
    width: var(--width, 0%);
    height: 100%;
    background-color: var(--bg-color, #4caf50);
    transition: width 0.5s ease-in-out, background-color 0.3s ease;
  }
}

input[type="file"]::file-selector-button {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 0.75rem;
}

.btn,
.link-button {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.85rem;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn-secondary {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.link-button {
  color: var(--primary);
  background: transparent;
  border-color: transparent;
}

.action-group,
.confirm-actions,
.action-buttons,
.logout-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;

  .inline-form {
    .btn-secondary {
      width: 100%;
    }
  }
}

.breadcrumb-nav {
  display: flex;
  gap: 0.75rem;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.folder-list,
.file-list,
.error-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  grid-auto-rows: 1fr;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 0.5rem;
}

.share-list,
.shared-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.folder-item,
.file-item,
.shared-file-item,
.error-item,
.empty-state {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 0.9rem;
  background: var(--surface-soft);
  color: var(--text);
}

.file-item {
  flex-direction: column;
  align-items: stretch;
}

.share-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;

  code {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    display: inline-block;
  }
}

.shared-file-item {
  flex-direction: column;

  .btn-primary {
    margin-top: auto;
  }
}

.error-item {
  background: var(--error-bg);
  border-left: 4px solid var(--danger);
}

.empty-state {
  font-style: italic;
  color: var(--muted);
}

.file-meta,
.share-expiry,
.confirm-details,
.file-meta-item {
  color: var(--muted);
  font-style: italic;
}

.file-image,
.shared-file-thumb {
  width: clamp(200px, 95vw, 400px);
  max-width: 100%;
  border-radius: 1rem;
  object-fit: cover;
}

.confirm-card {
  display: grid;
  gap: 1rem;
}

.warning-text {
  color: var(--danger);
  font-weight: 600;
}

footer {
  padding: 0.5rem 0;
  text-align: center;

  a {
    text-decoration: none;
    color: var(--primary);
  }
}

@media (max-width: 720px) {

  .page-header,
  .confirm-actions,
  .action-group,
  .file-item {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header {
    gap: 0.75rem;
  }
}

/* APP STYLES END HERE */