/* ============================================
   palota79.it — Stile pannello admin
   Design: dark theme, premium, funzionale
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --border-focus: #3b82f6;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59,130,246,0.1);
  --success: #10b981;
  --success-light: rgba(16,185,129,0.1);
  --danger: #ef4444;
  --danger-light: rgba(239,68,68,0.1);
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
}

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* === Login === */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: 16px;
  display: none;
}

/* === Dashboard Stats Grid === */
.stats-grid-main {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stats-grid-client {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 860px) {
  .stats-grid-main, .stats-grid-client {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .stats-grid-main, .stats-grid-client {
    grid-template-columns: 1fr;
  }
}

/* === Dashboard === */
.dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.dash-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.dash-actions {
  display: flex;
  gap: 10px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--accent-light);
  color: var(--text);
  border-color: var(--accent);
}

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

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

/* === Form === */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === Invoice List === */
.invoice-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.invoice-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s ease;
}

.invoice-item:hover {
  border-color: var(--accent);
}

.inv-num {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  min-width: 110px;
}

.inv-client {
  font-weight: 500;
  font-size: 1rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-amount {
  font-weight: 600;
  font-size: 1.1rem;
  white-space: nowrap;
}

.inv-actions {
  display: flex;
  gap: 10px;
}

@media (max-width: 640px) {
  .invoice-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .inv-actions {
    justify-content: flex-start;
  }
}

/* === Card / Panel === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* === Items editor === */
.items-editor {
  margin-bottom: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 120px 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}

.item-row .form-input {
  margin-bottom: 0;
}

.remove-item-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger-light);
  color: var(--danger);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.125rem;
  transition: all 0.2s;
}
.remove-item-btn:hover {
  background: var(--danger);
  color: #fff;
}

.add-item-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.add-item-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* === Toast notification === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--success);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state p {
  margin-bottom: 16px;
}

/* === Checkbox === */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.checkbox-group label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* === File upload === */
.file-upload {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.file-upload:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.file-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-upload-text {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.file-upload-name {
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 4px;
}

/* === Utility === */
.hidden { display: none !important; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
