:root {
  --bg: #f4f6f8;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --border-color: #e5e7eb;
  --border-light: #f0f2f5;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --primary: #398860;
  --primary-hover: #2d6e4d;
  --primary-soft: rgba(57, 136, 96, 0.1);
  --primary-light: #eaf4ee;
  --success: #10b981;
  --success-hover: #059669;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --info: #0284c7;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08);
  --transition: all 0.2s ease-in-out;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Montserrat', sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
}

/* ==================== LOGIN PAGE ==================== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eaf4ee 0%, #f4f6f8 100%);
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  padding: 35px 30px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.login-logo {
  text-align: center;
  margin-bottom: 25px;
}

.login-logo img {
  max-height: 48px;
  max-width: 220px;
  margin-bottom: 12px;
}

.login-logo h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 13px;
}

.login-footer {
  margin-top: 25px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ==================== ADMIN LAYOUT ==================== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-brand img {
  max-height: 38px;
  max-width: 190px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px 6px;
  letter-spacing: 0.5px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  transition: var(--transition);
}

.sidebar-nav a i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.sidebar-nav a:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.sidebar-nav a:hover i {
  color: var(--primary);
}

.sidebar-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-nav a.active i {
  color: var(--primary);
}

.sidebar-footer {
  padding: 15px 12px;
  border-top: 1px solid var(--border-color);
  background: #fafafa;
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-footer a:hover {
  color: var(--text-primary);
  background: var(--border-color);
}

.sidebar-footer a.logout:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 30px;
  min-width: 0;
}

/* ==================== PAGE HEADER ==================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
  flex-wrap: wrap;
  gap: 15px;
}

.page-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-title p {
  font-size: 13px;
  color: var(--text-secondary);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==================== CARDS & CONTAINERS ==================== */
.content-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 25px;
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header-flex h3 {
  font-size: 16px;
  font-weight: 600;
}

/* ==================== FORMS & INPUTS ==================== */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group select,
.form-group textarea,
.select-wrapper select,
.filters-card select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background-color: #ffffff;
  transition: var(--transition);
}

/* Custom Styled Select con icona SVG a freccia moderna */
select,
.form-group select,
.select-wrapper select,
.filters-card select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 10px 38px 10px 14px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23398860' stroke-width='2.2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 15px !important;
  cursor: pointer;
  border-radius: var(--radius-md) !important;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

select:hover,
.form-group select:hover,
.select-wrapper select:hover,
.filters-card select:hover {
  border-color: #9ca3af;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.form-group textarea {
  min-height: 90px;
  resize: vertical;
}

.link-hover-primary {
  transition: var(--transition);
}
.link-hover-primary:hover {
  color: var(--primary) !important;
  text-decoration: underline !important;
}


.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Specificità alta per input con icona */
.form-group .input-icon-group {
  position: relative;
  display: flex;
  align-items: center;
}

.form-group .input-icon-group i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.form-group .input-icon-group input[type="text"],
.form-group .input-icon-group input[type="password"],
.form-group .input-icon-group input[type="email"] {
  padding-left: 42px !important;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  line-height: 1.4;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #f3f4f6;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: #e5e7eb;
}

.btn-success {
  background-color: var(--success);
  color: #fff;
}
.btn-success:hover {
  background-color: var(--success-hover);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background-color: var(--danger-hover);
}

.btn-outline-danger {
  background-color: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-outline-danger:hover {
  background-color: var(--danger);
  color: #fff;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ==================== ALERTS ==================== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-danger {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background-color: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-info {
  background-color: #f0f9ff;
  color: #075985;
  border: 1px solid #bae6fd;
}

/* ==================== FILTERS BAR ==================== */
.filters-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 18px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.filters-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-item {
  flex: 1;
  min-width: 200px;
}

.filter-item label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ==================== TABLES ==================== */
.table-responsive {
  overflow-x: auto;
}

.table-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-custom th {
  background-color: #f9fafb;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.table-custom td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: 13.5px;
  color: var(--text-primary);
}

.table-custom tbody tr {
  transition: var(--transition);
}

.table-custom tbody tr:hover {
  background-color: #fcfdfd;
}

.table-custom .drag-handle {
  cursor: grab;
  color: var(--text-muted);
  width: 36px;
  text-align: center;
  font-size: 16px;
}

.table-custom .drag-handle:hover {
  color: var(--primary);
}

.table-custom .drag-handle:active {
  cursor: grabbing;
}

.img-preview-table {
  width: 60px;
  height: 45px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #f0f0f0;
}

/* ==================== PHOTO GALLERY / GRID ==================== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 15px;
}

.gallery-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
}

.gallery-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.gallery-card-img-wrap {
  position: relative;
  width: 100%;
  padding-top: 66%; /* 3:2 ratio */
  background: #f4f6f8;
  overflow: hidden;
}

.gallery-card-img-wrap img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-card-body {
  padding: 12px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.gallery-card-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

.gallery-card-footer {
  padding: 10px 14px;
  background: #fafafa;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gallery-card .drag-handle-card {
  cursor: grab;
  color: var(--text-muted);
  font-size: 15px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}

.gallery-card .drag-handle-card:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.sortable-ghost {
  opacity: 0.35;
  background: var(--primary-light) !important;
  border: 2px dashed var(--primary) !important;
}

/* ==================== DROP ZONE / UPLOAD ==================== */
.upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px 20px;
  text-align: center;
  background-color: #fafbfc;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 20px;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.upload-dropzone i {
  font-size: 36px;
  color: var(--primary);
  margin-bottom: 10px;
}

.upload-dropzone h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-dropzone p {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Progress bar per upload */
.upload-progress-container {
  display: none;
  margin-top: 15px;
}

.upload-progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.2s ease;
}

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: var(--transition);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-color);
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* ==================== BADGES ==================== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-secondary {
  background: #f3f4f6;
  color: var(--text-secondary);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
  .sidebar {
    width: 70px;
  }
  .sidebar-brand img {
    display: none;
  }
  .sidebar-brand::after {
    content: "NV";
    font-weight: 800;
    color: var(--primary);
    font-size: 18px;
  }
  .sidebar-section-title {
    display: none;
  }
  .sidebar-nav a span,
  .sidebar-footer a span {
    display: none;
  }
  .sidebar-nav a {
    justify-content: center;
    padding: 12px;
  }
  .sidebar-footer a {
    justify-content: center;
    padding: 10px;
  }
  .main-content {
    margin-left: 70px;
    padding: 20px;
  }
}

@media (max-width: 600px) {
  .admin-layout {
    flex-direction: column;
  }
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-nav {
    display: flex;
    padding: 8px;
    overflow-x: auto;
  }
  .sidebar-footer {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 15px;
  }
  .filters-row {
    flex-direction: column;
  }
  .filter-item {
    width: 100%;
  }
}
