* { box-sizing: border-box; }
body {
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  background: #f4f5f7;
  color: #222;
}
.hidden { display: none !important; }

.view { min-height: 100vh; }

#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: white;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  width: 340px;
  text-align: center;
}
.login-box h1 { margin-top: 0; font-size: 1.3rem; display: flex; align-items: center; justify-content: center; gap: 0.5rem; white-space: nowrap; }
.login-logo { height: 24px; width: auto; }
.login-box input {
  width: 100%;
  padding: 0.6rem;
  margin: 0.4rem 0;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
}
.login-box button {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.8rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}
.error { color: #dc2626; font-size: 0.85rem; min-height: 1.2em; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: white;
  border-bottom: 1px solid #e5e7eb;
}
header h1 { font-size: 1.2rem; margin: 0; display: flex; align-items: center; gap: 0.8rem; }
.header-logo { height: 32px; width: auto; }
.header-right { display: flex; align-items: center; gap: 1rem; }
#logout-btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
}

#breadcrumb {
  padding: 0.8rem 1.5rem;
  font-size: 0.9rem;
  color: #555;
}
#breadcrumb span {
  cursor: pointer;
  color: #2563eb;
}

#upload-area {
  padding: 0 1.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
#upload-btn {
  padding: 0.4rem 0.8rem;
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#file-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}
#file-table th, #file-table td {
  text-align: left;
  padding: 0.6rem 1.5rem;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}
#file-table th:first-child, #file-table td:first-child { padding-right: 0; width: 2rem; }
#file-table tr.folder-row { cursor: pointer; }
#file-table tr.folder-row:hover { background: #f9fafb; }
.file-name { display: flex; align-items: center; gap: 0.5rem; }
.download-link { color: #2563eb; text-decoration: none; font-size: 0.85rem; }

#toolbar {
  padding: 0 1.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
#upload-area, #mkdir-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
#mkdir-area input[type="text"] {
  padding: 0.4rem;
  border: 1px solid #ddd;
  border-radius: 6px;
}
#upload-btn, #mkdir-btn {
  padding: 0.4rem 0.8rem;
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
#action-status { font-size: 0.85rem; color: #555; }

.secondary-btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
}

/* ---- Admin ---- */
#admin-section { padding: 1.5rem; }
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.admin-tab-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
}
.admin-tab-btn.active { background: #2563eb; color: white; border-color: #2563eb; }
#back-to-files-btn { margin-left: auto; }

.admin-tab h2 { margin-top: 0; }

#users-table, #logs-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  margin-bottom: 1.5rem;
}
#users-table th, #users-table td, #logs-table th, #logs-table td {
  text-align: left;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid #eee;
  font-size: 0.85rem;
}

.link-btn {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  margin-right: 0.6rem;
}
.link-btn.danger { color: #dc2626; }

.admin-form {
  background: white;
  padding: 1.2rem;
  border-radius: 10px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.admin-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: #444;
  gap: 0.25rem;
}
.admin-form input, .admin-form select {
  padding: 0.45rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
}
.checkbox-label { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }
.checkbox-label input { width: auto; }
.form-actions { display: flex; gap: 0.6rem; }
.admin-form button[type="submit"] {
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.hint { font-size: 0.8rem; color: #777; margin-top: -0.3rem; }
#settings-status { font-size: 0.85rem; color: #16a34a; }

.folders-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.folders-label { font-size: 0.85rem; color: #444; }
.folder-row-editor {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.folder-row-editor .folder-name-input {
  flex: 1;
  padding: 0.4rem;
  border: 1px solid #ddd;
  border-radius: 6px;
}
.folder-row-editor .folder-permission-select {
  padding: 0.4rem;
  border: 1px solid #ddd;
  border-radius: 6px;
}
.small-btn { align-self: flex-start; font-size: 0.8rem; padding: 0.3rem 0.6rem; }

/* ---- Barra utilizzo spazio ---- */
#usage-bar-container {
  padding: 0 1.5rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.usage-bar {
  flex: 1;
  max-width: 300px;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
#usage-bar-fill {
  height: 100%;
  background: #2563eb;
  transition: width 0.3s;
}
#usage-bar-fill.usage-warning { background: #dc2626; }
#usage-bar-label { font-size: 0.8rem; color: #555; }

/* ---- Ricerca ---- */
#search-area { display: flex; gap: 0.4rem; align-items: center; }
#search-input {
  padding: 0.4rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  min-width: 220px;
}
.search-folder-badge { color: #888; font-size: 0.8rem; }

/* ---- Drag & drop ---- */
#drop-zone {
  margin: 0 1.5rem 1rem;
  padding: 1.2rem;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
}
#drop-zone.drop-active { border-color: #2563eb; color: #2563eb; background: #eff6ff; }

/* ---- Sezioni secondarie (cestino, condivisioni, password) ---- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
}
#trash-section, #shares-section, #password-section { padding-bottom: 1.5rem; }
#trash-table, #shares-table {
  width: calc(100% - 3rem);
  margin: 0 1.5rem;
  border-collapse: collapse;
  background: white;
}
#trash-table th, #trash-table td, #shares-table th, #shares-table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #eee;
  font-size: 0.85rem;
}
#password-section .admin-form { margin: 0 1.5rem; }
.success-text { color: #16a34a; font-size: 0.85rem; }

.clickable { cursor: pointer; }
.clickable:hover { text-decoration: underline; color: #2563eb; }

/* ---- Modale anteprima ---- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-content {
  position: relative;
  background: white;
  border-radius: 10px;
  padding: 1rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
}
.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #eee;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
}
#preview-body img { max-width: 80vw; max-height: 80vh; display: block; }
#preview-body iframe { width: 80vw; height: 80vh; border: none; }

/* ---- Tabella avvisi ---- */
#alerts-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}
#alerts-table th, #alerts-table td {
  text-align: left;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid #eee;
  font-size: 0.85rem;
}

.admin-form h3 { margin: 0.5rem 0 0; font-size: 1rem; border-top: 1px solid #eee; padding-top: 1rem; }

#admin-shares-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  margin-top: 1rem;
}
#admin-shares-table th, #admin-shares-table td {
  text-align: left;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid #eee;
  font-size: 0.85rem;
}
