/* ============================================================
   DHOXA FILE MANAGER - MODERN DESIGN
   Interface completamente rivista con design professionale
============================================================ */

/* ============================================================
   RESET & BASE STYLES
============================================================ */
.afm-container * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.afm-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  margin: 20px 0;
  padding: 32px;
}

.afm-container h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 24px;
  color: #5C2028;
  background: linear-gradient(135deg, #5C2028 0%, #7a2a35 100%);
  color: white;
  padding: 24px;
  margin: -32px -32px 24px -32px;
  border-radius: 16px 16px 0 0;
}

/* ============================================================
   PATH & NAVIGATION
============================================================ */
.afm-path {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
}

/* ============================================================
   BUTTONS
============================================================ */
.afm-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  background: linear-gradient(135deg, #5C2028 0%, #7a2a35 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(92, 32, 40, 0.3);
}

.afm-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(92, 32, 40, 0.4);
  background: linear-gradient(135deg, #6d2530 0%, #8a3240 100%);
}

#afm-back {
  background: linear-gradient(135deg, #5C2028 0%, #7a2a35 100%);
  margin-bottom: 10px;
}

/* ============================================================
   FILE LIST
============================================================ */
#afm-list {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  margin-bottom: 24px;
  overflow: hidden;
}

.afm-file-row,
.afm-folder-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.2s ease;
}

.afm-file-row:last-child,
.afm-folder-row:last-child {
  border-bottom: none;
}

.afm-file-row:hover,
.afm-folder-row:hover {
  background: #f8fafc;
}

.afm-file-name {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.afm-file-icon {
  font-size: 20px;
  flex-shrink: 0;
  color: #5C2028;
}

.afm-file-name a,
.afm-open-folder {
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  text-decoration: none;
  cursor: pointer;
}

.afm-open-folder {
  color: #5C2028;
  font-weight: 600;
}

.afm-open-folder:hover {
  text-decoration: underline;
}

.afm-file-name a:hover {
  color: #5C2028;
}

/* NASCONDO COMPLETAMENTE IL CESTINO */
.afm-delete,
.afm-delete-folder {
  display: none !important;
}

/* ============================================================
   UPLOAD FORM
============================================================ */
#afm-upload-form {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 24px;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #fafbfc;
  margin-bottom: 24px;
  transition: all 0.3s ease;
}

#afm-upload-form:hover {
  border-color: #5C2028;
  background: #fff5f6;
}

#afm-upload-form input[type="file"] {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  transition: all 0.2s ease;
}

#afm-upload-form input[type="file"]:focus {
  outline: none;
  border-color: #5C2028;
  box-shadow: 0 0 0 3px rgba(92, 32, 40, 0.15);
}

/* ============================================================
   RESPONSE MESSAGES
============================================================ */
#afm-response {
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: #fff5f6;
  color: #5C2028;
  border: 1px solid #fecaca;
  margin-top: 16px;
}

#afm-response:empty {
  display: none;
}

.afm-msg {
  padding: 16px 20px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 14px;
  font-weight: 500;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* ============================================================
   EMPTY STATE
============================================================ */
#afm-list:empty::after {
  content: "Nessun file o cartella presente";
  display: block;
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-style: italic;
}

/* ============================================================
   RESPONSIVE DESIGN
============================================================ */
@media (max-width: 768px) {
  .afm-container {
    padding: 16px;
    margin: 10px;
  }

  .afm-container h2 {
    font-size: 24px;
    padding: 20px;
    margin: -16px -16px 16px -16px;
  }

  #afm-upload-form {
    flex-direction: column;
    padding: 16px;
  }

  #afm-upload-form input[type="file"] {
    width: 100%;
  }

  .afm-btn {
    width: 100%;
    justify-content: center;
  }

  .afm-file-row,
  .afm-folder-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .afm-container {
    border-radius: 12px;
  }

  .afm-btn {
    padding: 8px 16px;
    font-size: 13px;
  }
}

/* ============================================================
   ANIMATIONS
============================================================ */
@keyframes afmSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.afm-file-row,
.afm-folder-row {
  animation: afmSlideIn 0.3s ease;
}

/* ============================================================
   UTILITY CLASSES
============================================================ */
.afm-hidden {
  display: none !important;
}

.afm-text-center {
  text-align: center;
}

/* Print Styles */
@media print {
  #afm-upload-form,
  .afm-btn,
  .afm-delete,
  .afm-delete-folder {
    display: none !important;
  }
}

/* ============================================================
   ADMIN PANEL STYLES
============================================================ */
.afm-admin {
  background: #ffffff;
  padding: 32px;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.afm-admin h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #5C2028;
  background: linear-gradient(135deg, #5C2028 0%, #7a2a35 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.afm-admin > p {
  font-size: 16px;
  color: #64748b;
  margin-bottom: 24px;
}

#afm-user-select {
  width: 100%;
  max-width: 400px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 24px;
}

#afm-user-select:focus {
  outline: none;
  border-color: #5C2028;
  box-shadow: 0 0 0 3px rgba(92, 32, 40, 0.15);
}

#afm-admin-panel {
  margin-top: 24px;
}

.afm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 20px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  margin-bottom: 20px;
}

.afm-upload-area {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: linear-gradient(135deg, #5C2028 0%, #7a2a35 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(92, 32, 40, 0.3);
}

.afm-upload-area:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(92, 32, 40, 0.4);
  background: linear-gradient(135deg, #6d2530 0%, #8a3240 100%);
}

#afm-folder-name {
  flex: 1;
  min-width: 200px;
  padding: 10px 16px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  transition: all 0.2s ease;
}

#afm-folder-name:focus {
  outline: none;
  border-color: #5C2028;
  box-shadow: 0 0 0 3px rgba(92, 32, 40, 0.15);
}

#afm-create-folder,
#afm-back,
#afm-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: linear-gradient(135deg, #5C2028 0%, #7a2a35 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(92, 32, 40, 0.3);
}

#afm-create-folder:hover,
#afm-back:hover,
#afm-refresh:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(92, 32, 40, 0.4);
  background: linear-gradient(135deg, #6d2530 0%, #8a3240 100%);
}

#afm-path {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
}

#afm-file-list {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  margin-bottom: 24px;
  overflow: hidden;
  min-height: 100px;
}

#afm-file-list:empty::after {
  content: "Nessun file o cartella presente";
  display: block;
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-style: italic;
}

#afm-admin-response {
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: #fff5f6;
  color: #5C2028;
  border: 1px solid #fecaca;
}

#afm-admin-response:empty {
  display: none;
}

/* Admin: mostra i cestini */
.afm-admin .afm-delete,
.afm-admin .afm-delete-folder {
  display: inline-flex !important;
  align-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: none;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.afm-admin .afm-delete:hover,
.afm-admin .afm-delete-folder:hover {
  background: #fef2f2;
  transform: scale(1.05);
}

/* ============================================================
   ADMIN RESPONSIVE
============================================================ */
@media (max-width: 768px) {
  .afm-admin {
    padding: 20px;
  }

  .afm-toolbar {
    flex-direction: column;
    padding: 16px;
  }

  .afm-toolbar > * {
    width: 100%;
  }

  #afm-folder-name {
    min-width: 100%;
  }
}