/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #22263a;
  --border: #2e3350;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --accent-light: rgba(108, 99, 255, 0.15);
  --text: #e8eaf6;
  --text2: #9095b0;
  --text3: #5c6080;
  --success: #4caf7d;
  --danger: #f44336;
  --warning: #ff9800;
  --note: #6c63ff;
  --password: #ff6b9d;
  --info: #00bcd4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: flex; }

/* ===== LOGIN ===== */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(108,99,255,0.2) 0%, transparent 70%), var(--bg);
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo { font-size: 56px; margin-bottom: 16px; }
.login-card h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.login-subtitle { color: var(--text2); margin-bottom: 32px; }

.input-group { text-align: left; margin-bottom: 20px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }

.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 48px; }
.toggle-pw {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 18px; opacity: 0.6;
  transition: opacity var(--transition);
}
.toggle-pw:hover { opacity: 1; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ===== APP LAYOUT ===== */
#app-screen {
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.logo { font-size: 24px; }
.logo-text { font-size: 18px; font-weight: 700; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text2);
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 18px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.top-bar h2 { flex: 1; font-size: 20px; font-weight: 700; }
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; }

.search-bar {
  position: relative;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.search-bar input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  font-size: 14px;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }
.search-icon { position: absolute; left: 36px; top: 50%; transform: translateY(-50%); font-size: 16px; pointer-events: none; }

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ===== TABS ===== */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== ENTRIES GRID ===== */
.entries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.entry-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.entry-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}
.entry-card[data-type="password"]::before { background: var(--password); }
.entry-card[data-type="info"]::before { background: var(--info); }

.entry-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(108,99,255,0.2);
}

.entry-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}
.entry-type-badge {
  font-size: 20px;
  line-height: 1;
}
.entry-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.entry-card:hover .entry-card-actions { opacity: 1; }

.entry-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-card-preview {
  color: var(--text2);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}
.entry-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text3);
}
.entry-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 500;
}

/* ===== FILES GRID ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 24px;
  background: var(--bg2);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-hint { color: var(--text3); font-size: 13px; margin-top: 4px; }

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.file-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
  position: relative;
}
.file-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.file-preview {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  overflow: hidden;
}
.file-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.file-size { font-size: 12px; color: var(--text3); margin-bottom: 12px; }
.file-actions { display: flex; gap: 8px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text2);
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state p { font-size: 16px; margin-bottom: 20px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { background: rgba(244,67,54,0.1); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 6px; border-radius: 6px; background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text2); transition: all var(--transition); }
.btn-icon:hover { background: var(--bg3); color: var(--text); }

/* ===== INPUTS ===== */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 120px; }
select option { background: var(--bg2); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}
.modal-wide { max-width: 680px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-header-actions { display: flex; align-items: center; gap: 8px; }
.modal-close {
  background: none; border: none; color: var(--text2);
  font-size: 20px; cursor: pointer; padding: 4px 8px;
  border-radius: 6px; transition: all var(--transition);
}
.modal-close:hover { background: var(--bg3); color: var(--text); }

.modal-body { padding: 24px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }

/* ===== VIEW MODAL ===== */
.view-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text2);
}
.view-content {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 16px;
  min-height: 80px;
  font-family: 'Courier New', monospace;
}
.view-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 320px;
}
.toast.hidden { display: none; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.info { border-color: var(--accent); color: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(2px);
}
.loading-overlay.hidden { display: none; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== UPLOAD PROGRESS ===== */
.upload-progress {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 13px;
}
.progress-bar-wrap {
  background: var(--bg);
  border-radius: 50px;
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 50px;
  transition: width 0.3s ease;
}

/* ===== COPY BUTTON ===== */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-light);
  color: var(--accent);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.copy-btn:hover { background: var(--accent); color: #fff; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .entries-grid { grid-template-columns: 1fr; }
  .files-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .login-card { padding: 32px 24px; }
  .content-area { padding: 16px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== HIDDEN ===== */
.hidden { display: none !important; }
