/* style.css — includes login screen + file browser + modal */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(145deg, #f6f9fc 0%, #e9f0f7 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.hidden { display: none !important; }

/* ========== LOGIN SCREEN ========== */
.login-screen {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: center;
}

.login-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 2rem;
  box-shadow: 0 25px 45px -12px rgba(0, 20, 40, 0.3);
  padding: 2.5rem 2rem 2rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.7);
  animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(15px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-icon {
  font-size: 3.2rem;
  margin-bottom: 0.8rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

.login-card h1 {
  font-size: 1.6rem;
  color: #0b2b3f;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.login-subtitle {
  font-size: 0.9rem;
  color: #5b7a8f;
  margin-bottom: 1.8rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  background: #ffffff;
  border: 1.5px solid #cddde9;
  border-radius: 50px;
  padding: 0.35rem 0.35rem 0.35rem 1.2rem;
  transition: 0.2s;
}

.input-group:focus-within {
  border-color: #1e5f7a;
  box-shadow: 0 0 0 4px rgba(30, 95, 122, 0.15);
}

#passwordInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  color: #0b2b3f;
  font-family: inherit;
}

#passwordInput::placeholder {
  color: #9bb2c2;
}

#loginBtn {
  background: #1e5f7a;
  color: white;
  border: none;
  padding: 0.7rem 1.6rem;
  border-radius: 40px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.15s;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 10px rgba(27, 77, 101, 0.25);
}

#loginBtn:hover {
  background: #0e445c;
  transform: scale(0.98);
}

#loginBtn:active {
  transform: scale(0.95);
}

#loginBtn:disabled {
  background: #7e9aa9;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  color: #b13e3e;
  font-size: 0.85rem;
  font-weight: 500;
  min-height: 1.2rem;
  padding: 0.2rem 0.5rem;
  background: #ffe3e3;
  border-radius: 20px;
  transition: 0.2s;
  opacity: 0;
}

.login-error.visible {
  opacity: 1;
  padding: 0.5rem 1rem;
}

/* shake animation for wrong password */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.shake { animation: shake 0.4s ease; }

/* ========== FILE BROWSER ========== */
.browser-screen {
  width: 100%;
  display: flex;
  justify-content: center;
  animation: fadeInUp 0.4s ease;
}

.browser-container {
  max-width: 780px;
  width: 100%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-radius: 2rem;
  box-shadow: 0 25px 45px -12px rgba(0, 20, 40, 0.3);
  padding: 1.8rem 1.8rem 1.2rem;
  border: 1px solid rgba(255,255,255,0.7);
}

header {
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #0b2b3f;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

h1::before {
  content: '🗂️';
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.subtitle {
  font-size: 0.95rem;
  color: #4b6b7f;
  margin-top: 0.2rem;
  margin-left: 0.2rem;
}

.subtitle code {
  background: #d9e6f0;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.85rem;
  color: #1d4b64;
  font-weight: 500;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  background: #ffffffd9;
  padding: 0.65rem 1rem;
  border-radius: 60px;
  border: 1px solid #cddde9;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

#refreshBtn, .logout-btn {
  background: #1e5f7a;
  border: none;
  color: white;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 1.2rem;
  border-radius: 40px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: 0.15s;
  box-shadow: 0 3px 8px rgba(27, 77, 101, 0.2);
  border: 1px solid #ffffff30;
}

#refreshBtn:hover { background: #0e445c; transform: scale(0.98); }
#refreshBtn:active { transform: scale(0.96); }

.logout-btn {
  background: #b13e3e;
  box-shadow: 0 3px 8px rgba(177, 62, 62, 0.25);
}

.logout-btn:hover {
  background: #8f2f2f;
  transform: scale(0.98);
}

.status {
  font-size: 0.85rem;
  color: #4d6a7c;
  background: #e3eef7;
  padding: 0.3rem 1rem;
  border-radius: 30px;
  font-weight: 500;
  transition: 0.2s;
}

/* ----- file tree ----- */
.file-tree {
  background: #ffffffec;
  border-radius: 1.5rem;
  padding: 1rem 0.8rem 0.8rem;
  min-height: 180px;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid #d4e3ed;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.02);
  scrollbar-width: thin;
  scrollbar-color: #b6cfdf #eef4f8;
}

.file-tree::-webkit-scrollbar { width: 8px; }
.file-tree::-webkit-scrollbar-track { background: #eef4f8; border-radius: 20px; }
.file-tree::-webkit-scrollbar-thumb { background: #b6cfdf; border-radius: 20px; }

.empty-placeholder {
  text-align: center;
  color: #7d98aa;
  font-style: italic;
  padding: 2.5rem 1rem;
  background: #f4f9fe;
  border-radius: 1.2rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.folder-item, .file-item { list-style: none; margin: 2px 0; }

.folder-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem 0.6rem 1rem;
  background: #f4faff;
  border-radius: 40px;
  font-weight: 600;
  color: #15516b;
  border: 1px solid #d1e2ef;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.folder-header:hover {
  background: #e6f2fd;
  border-color: #b3d2e8;
}

.folder-icon { font-size: 1.3rem; line-height: 1; }
.folder-name { font-size: 1rem; letter-spacing: -0.01em; word-break: break-word; }

.file-list {
  margin-left: 1.8rem;
  margin-top: 0.2rem;
  padding-left: 0.6rem;
  border-left: 2px dashed #b8d2e7;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.9rem 0.4rem 1.2rem;
  background: #ffffff;
  border-radius: 30px;
  color: #2e4d62;
  font-size: 0.95rem;
  border: 1px solid #e0eef9;
  transition: 0.1s;
  word-break: break-word;
  cursor: pointer;
}

.file-item:hover {
  background: #f6fcff;
  border-color: #b8d9f0;
  transform: translateX(3px);
}

.file-icon { font-size: 1.1rem; opacity: 0.9; flex-shrink: 0; }
.file-name { font-weight: 450; flex: 1; }

.file-download-btn {
  background: transparent;
  border: none;
  color: #3b6e8e;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  transition: 0.15s;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.file-download-btn:hover {
  background: #d7e9f7;
  border-color: #b1cee6;
  color: #154a66;
}

.empty-folder-hint {
  font-size: 0.85rem;
  color: #90a9bb;
  font-style: italic;
  padding: 0.3rem 0.5rem 0.3rem 1.8rem;
  background: #f5f9fe;
  border-radius: 30px;
  display: inline-block;
  width: fit-content;
}

.footnote {
  margin-top: 1.2rem;
  font-size: 0.75rem;
  color: #6f8fa5;
  text-align: center;
  border-top: 1px solid #d2e3f0;
  padding-top: 0.9rem;
}

.footnote code {
  background: #dcebf8;
  padding: 0.15rem 0.5rem;
  border-radius: 16px;
  font-size: 0.7rem;
  color: #0f4157;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(10, 25, 35, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: 0.2s ease;
  padding: 1.5rem;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-content {
  background: #ffffff;
  border-radius: 2rem;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 70px -20px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: scale(0.95);
  transition: 0.2s ease;
}

.modal-overlay.active .modal-content { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.2rem 0.9rem 1.5rem;
  border-bottom: 1px solid #dce9f2;
  background: #f6fcff;
  gap: 0.5rem;
}

.modal-filename {
  font-weight: 600;
  color: #14506b;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.modal-actions { display: flex; align-items: center; gap: 0.6rem; }

.modal-download-btn {
  background: #1e5f7a;
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: 0.15s;
  border: 1px solid #ffffff30;
  box-shadow: 0 3px 8px rgba(27, 77, 101, 0.2);
  white-space: nowrap;
}

.modal-download-btn:hover { background: #0e445c; transform: scale(0.98); }

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: #4d6a7c;
  cursor: pointer;
  padding: 0.1rem 0.5rem;
  border-radius: 50%;
  transition: 0.1s;
}

.modal-close-btn:hover { background: #e3eef7; color: #b13e3e; }

.modal-body {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f6fb;
  overflow: auto;
  min-height: 200px;
  max-height: 70vh;
}

.modal-body img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: 0.8rem;
  box-shadow: 0 10px 25px -8px rgba(0, 0, 0, 0.2);
}

@media (max-width: 480px) {
  .browser-container { padding: 1.2rem; }
  h1 { font-size: 1.5rem; }
  .file-list { margin-left: 0.8rem; }
  .modal-filename { max-width: 100%; }
  .toolbar { justify-content: center; }
}