@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #f0f0f0;
  --surface:    #ffffff;
  --panel:      #e8e8e8;
  --border:     #b0b0b0;
  --border2:    #d4d4d4;
  --accent:     #0054a6;
  --accent2:    #18b818;
  --accent-bg:  #cce0f5;
  --accent-txt: #ffffff;
  --danger:     #cc0000;
  --text:       #1a1a1a;
  --muted:      #666666;
  --row-hover:  #e5f0fb;
  --row-sel:    #cce0f5;
  --radius:     3px;
  --font:       'Noto Sans', Tahoma, Geneva, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  min-height: 100vh;
}

/* ── layout ── */
.wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* ── header / toolbar ── */
.header {
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
}
.header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-title::before {
  content: '🗂';
  font-size: 16px;
}
.nav { display: flex; gap: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(to bottom, #f8f8f8, #e0e0e0);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: inset 0 1px 0 #fff;
  transition: background .1s;
}
.btn:hover { background: linear-gradient(to bottom, #e8f0fb, #ccddf5); border-color: var(--accent); }
.btn:active { background: linear-gradient(to bottom, #d0e4f7, #b8cfe8); box-shadow: none; }
.btn.btn-primary {
  background: linear-gradient(to bottom, #1a7ad4, #0054a6);
  border-color: #004a94;
  color: #fff;
  box-shadow: inset 0 1px 0 #4fa3e0;
}
.btn.btn-primary:hover { background: linear-gradient(to bottom, #2288e0, #0060b8); }
.btn.btn-danger { color: var(--danger); border-color: #d88; }
.btn.btn-danger:hover { background: linear-gradient(to bottom, #fff0f0, #f5cccc); }

/* ── address bar ── */
.addressbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-bottom: none;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.addressbar .path {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12px;
  color: var(--text);
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  padding: 1px 4px;
  border-radius: 2px;
}
.breadcrumb a:hover { text-decoration: underline; background: var(--accent-bg); }
.breadcrumb .sep { color: var(--border); padding: 0 2px; }

/* ── file list ── */
.file-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-bottom: none;
}
.file-list-header {
  display: grid;
  grid-template-columns: 28px 1fr 90px;
  padding: 4px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.file-item {
  display: grid;
  grid-template-columns: 28px 1fr 90px;
  align-items: center;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border2);
  transition: background .08s;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--row-hover); }
.file-icon { font-size: 15px; line-height: 1; }
.file-name a {
  color: var(--text);
  text-decoration: none;
}
.file-name a:hover { color: var(--accent); text-decoration: underline; }
.file-name.is-dir a { color: var(--accent); font-weight: 600; }
.file-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.file-actions a {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid transparent;
}
.file-actions a:hover { border-color: var(--border); background: var(--panel); color: var(--text); }
.file-actions a.del { color: var(--danger); }
.file-actions a.del:hover { border-color: #d88; background: #fff0f0; }

.back-row {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border2);
  display: grid;
  grid-template-columns: 28px 1fr 90px;
  align-items: center;
}
.back-row:hover { background: var(--row-hover); }
.back-row a { color: var(--accent); text-decoration: none; font-size: 12px; }
.back-row a:hover { text-decoration: underline; }

/* ── status bar ── */
.statusbar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 1px solid var(--border2);
  padding: 3px 10px;
  font-size: 11px;
  color: var(--muted);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── forms / cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.card h2 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border2);
  color: var(--text);
}
.form-group { margin-bottom: 12px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=password], select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 5px 8px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg), inset 0 1px 2px rgba(0,0,0,.08); }
.form-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.form-actions a { color: var(--muted); text-decoration: none; font-size: 12px; }
.form-actions a:hover { color: var(--accent); text-decoration: underline; }

/* ── alerts ── */
.alert { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 12px; }
.alert-error { background: #fff0f0; border: 1px solid #e8b0b0; color: var(--danger); }
.alert-success { background: #f0fff4; border: 1px solid #9dd8b0; color: #1a7a40; }

/* ── login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.login-sub { color: var(--muted); font-size: 11px; margin-bottom: 20px; font-family: Consolas, monospace; }

/* ── upload ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: var(--panel);
  transition: border-color .15s, background .15s;
  margin-bottom: 12px;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.upload-zone input[type=file] { display: none; }
.upload-zone .icon { font-size: 28px; margin-bottom: 6px; }

/* ── editor ── */
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.editor-header h2 { font-size: 13px; font-weight: 600; font-family: Consolas, monospace; color: var(--text); }
.editor-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.1);
}

.status-ok { color: var(--accent2) !important; }
.status-error { color: var(--danger) !important; }

/* ── icon view (grid mode) ── */

/* Applichiamo la griglia al contenitore dei file */
.file-list.icon-view #fileItems {
    display: grid !important;
    /* Crea colonne automatiche da 110px */
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 15px;
    padding: 20px;
}

/* Modifichiamo il layout dell'item da riga a quadratino */
.icon-view .file-item, 
.icon-view .back-row,
.icon-view .back-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    width: 100%;
    height: 120px;
    padding: 10px;
    border: 1px solid transparent;
    border-bottom: none !important; /* Rimuove la riga della vista lista */
    transition: all 0.2s;
    cursor: pointer;
    border-radius: var(--radius);
}

/* Effetto selezione e hover nella griglia */
.icon-view .file-item:hover,
.icon-view .back-row:hover {
    background: var(--row-hover);
    border-color: var(--border2);
}

.icon-view .file-item.selected {
    background: var(--row-sel);
    border-color: var(--accent);
}

/* Ingrandiamo l'icona per la vista a griglia */
.icon-view .file-icon {
    font-size: 42px; /* Dimensione grande tipo Windows */
    margin-bottom: 8px;
    display: block;
}

/* Regoliamo il nome del file per la griglia */
.icon-view .file-name {
    font-size: 11px;
    line-height: 1.2;
    max-width: 100%;
    word-break: break-all;
    /* Tronca il testo se troppo lungo (max 2 righe) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Nascondiamo la colonna azioni/dimensioni nella vista icone */
.icon-view .file-actions,
.icon-view .file-list-header {
    display: none;
}
/* Effetto selezione Windows Style */
.icon-view .file-item.selected {
    background-color: var(--row-sel) !important;
    border: 1px solid var(--accent) !important;
}

/* Stile opzionale per i bottoni quando selezionati */
#btnList.active, #btnIcons.active {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}

/* Allinea l'icona e il testo del back */
.icon-view .back-row .file-icon,
.icon-view .back-item .file-icon {
    font-size: 45px;
    margin-bottom: 8px;
}

.icon-view .back-row div:last-child,
.icon-view .back-item div:last-child {
    font-size: 12px;
    font-weight: bold;
}