@import "tailwindcss";

/* Progetto Legno Design System */
:root {
  /* Brand Colors */
  --pl-orange: #EB5E2B;
  --pl-orange-dark: #D14E1E;
  --pl-orange-light: #FF7744;
  --pl-green: #95C11F;
  --pl-green-dark: #7BA318;
  --pl-green-light: #A8D42A;

  /* Wood Tones */
  --pl-wood-100: #FDF8F3;
  --pl-wood-200: #F5E6D3;
  --pl-wood-300: #E8D0B3;
  --pl-wood-400: #D4A574;
  --pl-wood-500: #8B6914;
  --pl-wood-600: #5C4A1F;
  --pl-wood-700: #3D321A;

  /* Neutrals */
  --pl-white: #FFFFFF;
  --pl-gray-50: #F9FAFB;
  --pl-gray-100: #F3F4F6;
  --pl-gray-200: #E5E7EB;
  --pl-gray-300: #D1D5DB;
  --pl-gray-400: #9CA3AF;
  --pl-gray-500: #6B7280;
  --pl-gray-600: #4B5563;
  --pl-gray-700: #374151;
  --pl-gray-800: #1F2937;
  --pl-gray-900: #111827;
  --pl-black: #0F0F0F;

  /* Semantic */
  --pl-success: #10B981;
  --pl-warning: #F59E0B;
  --pl-error: #EF4444;
  --pl-info: #3B82F6;

  /* Backgrounds */
  --background: var(--pl-white);
  --foreground: var(--pl-black);
  --background-secondary: var(--pl-gray-50);
  --background-tertiary: var(--pl-wood-100);

  /* Sidebar */
  --sidebar-bg: var(--pl-gray-900);
  --sidebar-text: var(--pl-gray-300);
  --sidebar-active: var(--pl-orange);
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", system-ui, sans-serif;

  /* Custom Colors */
  --color-pl-orange: var(--pl-orange);
  --color-pl-orange-dark: var(--pl-orange-dark);
  --color-pl-orange-light: var(--pl-orange-light);
  --color-pl-green: var(--pl-green);
  --color-pl-green-dark: var(--pl-green-dark);
  --color-pl-green-light: var(--pl-green-light);

  --color-wood-100: var(--pl-wood-100);
  --color-wood-200: var(--pl-wood-200);
  --color-wood-300: var(--pl-wood-300);
  --color-wood-400: var(--pl-wood-400);
  --color-wood-500: var(--pl-wood-500);
  --color-wood-600: var(--pl-wood-600);
  --color-wood-700: var(--pl-wood-700);

  --color-success: var(--pl-success);
  --color-warning: var(--pl-warning);
  --color-error: var(--pl-error);
  --color-info: var(--pl-info);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: var(--pl-gray-900);
    --foreground: var(--pl-gray-100);
    --background-secondary: var(--pl-gray-800);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--pl-gray-100);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--pl-gray-300);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--pl-gray-400);
}

/* Focus styles */
*:focus-visible {
  outline: 2px solid var(--pl-orange);
  outline-offset: 2px;
}

/* Form elements */
input, select, textarea {
  font-family: inherit;
}

/* Buttons base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--pl-orange);
  color: white;
}

.btn-primary:hover {
  background: var(--pl-orange-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(235, 94, 43, 0.25);
}

.btn-secondary {
  background: var(--pl-gray-100);
  color: var(--pl-gray-700);
  border: 1px solid var(--pl-gray-200);
}

.btn-secondary:hover {
  background: var(--pl-gray-200);
  border-color: var(--pl-gray-300);
}

.btn-success {
  background: var(--pl-green);
  color: white;
}

.btn-success:hover {
  background: var(--pl-green-dark);
}

/* Card styles */
.card {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--pl-gray-200);
}

.card-hover:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  transition: all 0.2s ease;
}

/* Gradient backgrounds */
.gradient-hero {
  background: linear-gradient(135deg, var(--pl-wood-100) 0%, var(--pl-wood-200) 100%);
}

.gradient-orange {
  background: linear-gradient(135deg, var(--pl-orange) 0%, var(--pl-orange-dark) 100%);
}

.gradient-green {
  background: linear-gradient(135deg, var(--pl-green) 0%, var(--pl-green-dark) 100%);
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
}

.badge-bozza { background: var(--pl-gray-100); color: var(--pl-gray-600); }
.badge-inviato { background: #DBEAFE; color: #1E40AF; }
.badge-visto { background: #FEF3C7; color: #92400E; }
.badge-accettato { background: #D1FAE5; color: #065F46; }
.badge-rifiutato { background: #FEE2E2; color: #991B1B; }
.badge-scaduto { background: #F3F4F6; color: #6B7280; }

/* Table styles */
.table-modern {
  width: 100%;
  border-collapse: collapse;
}

.table-modern th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pl-gray-500);
  background: var(--pl-gray-50);
  border-bottom: 1px solid var(--pl-gray-200);
}

.table-modern td {
  padding: 1rem;
  border-bottom: 1px solid var(--pl-gray-100);
}

.table-modern tbody tr:hover {
  background: var(--pl-gray-50);
}

/* Input styles */
.input-modern {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  border: 1px solid var(--pl-gray-300);
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  background: white;
}

.input-modern:focus {
  border-color: var(--pl-orange);
  box-shadow: 0 0 0 3px rgba(235, 94, 43, 0.1);
  outline: none;
}

.input-modern::placeholder {
  color: var(--pl-gray-400);
}

/* Label styles */
.label-modern {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--pl-gray-700);
  margin-bottom: 0.375rem;
}

/* Animation utilities */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.animate-slideIn {
  animation: slideIn 0.3s ease forwards;
}

/* Print styles - Optimized for A4 */
@media print {
  .no-print { display: none !important; }
  .page-break-before { page-break-before: always; }
  .page-break-after { page-break-after: always; }
  .avoid-break { break-inside: avoid; }

  @page {
    size: A4;
    margin: 15mm 12mm 15mm 12mm;
  }

  html, body {
    width: 210mm;
    min-height: 297mm;
    background: white !important;
    color: black !important;
    font-size: 10pt;
    line-height: 1.4;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  * {
    box-shadow: none !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Container */
  .max-w-4xl {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Header styling */
  header {
    text-align: center;
    margin-bottom: 8mm !important;
    padding-bottom: 5mm !important;
    border-bottom: 2pt solid var(--pl-orange) !important;
  }

  header h1 {
    font-size: 18pt !important;
    margin-bottom: 2mm !important;
  }

  /* Section styling */
  section {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 6mm !important;
  }

  section h2 {
    font-size: 12pt !important;
    margin-bottom: 4mm !important;
    padding-bottom: 2mm !important;
    border-bottom: 1pt solid var(--pl-orange) !important;
  }

  /* Tables */
  table {
    break-inside: avoid;
    page-break-inside: avoid;
    width: 100%;
    font-size: 9pt;
  }

  table th {
    font-size: 8pt;
    padding: 3mm 2mm !important;
    background: #f5f5f5 !important;
  }

  table td {
    padding: 2mm !important;
    border-bottom: 0.5pt solid #ddd;
  }

  /* Images */
  img {
    max-width: 100%;
    height: auto;
    page-break-inside: avoid;
  }

  /* Fase cards */
  .rounded-t-xl,
  .rounded-b-xl,
  .rounded-xl {
    border-radius: 2mm !important;
  }

  /* Text sizing */
  p, li, span {
    font-size: 9pt;
    line-height: 1.4;
  }

  .text-sm {
    font-size: 8pt !important;
  }

  .text-xs {
    font-size: 7pt !important;
  }

  .text-lg {
    font-size: 11pt !important;
  }

  .text-xl {
    font-size: 13pt !important;
  }

  .text-2xl {
    font-size: 14pt !important;
  }

  .text-4xl {
    font-size: 18pt !important;
  }

  /* Margins and padding reduction */
  .mb-10 {
    margin-bottom: 6mm !important;
  }

  .mb-6 {
    margin-bottom: 4mm !important;
  }

  .mb-4 {
    margin-bottom: 3mm !important;
  }

  .p-6 {
    padding: 4mm !important;
  }

  .p-8 {
    padding: 5mm !important;
  }

  .px-6 {
    padding-left: 4mm !important;
    padding-right: 4mm !important;
  }

  .py-4 {
    padding-top: 3mm !important;
    padding-bottom: 3mm !important;
  }

  /* Grid adjustments */
  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .gap-6 {
    gap: 4mm !important;
  }

  .gap-4 {
    gap: 3mm !important;
  }

  /* Keep colors visible */
  .bg-\[var\(--pl-orange\)\] {
    background-color: var(--pl-orange) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .bg-\[var\(--pl-gray-900\)\] {
    background-color: var(--pl-gray-900) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .text-\[var\(--pl-orange\)\] {
    color: var(--pl-orange) !important;
  }

  /* Borders */
  .border-\[var\(--pl-orange\)\] {
    border-color: var(--pl-orange) !important;
  }

  /* Footer */
  footer {
    margin-top: 8mm !important;
    padding-top: 4mm !important;
  }

  /* Link styling for print */
  a {
    text-decoration: none;
    color: inherit;
  }

  /* Keep whitespace pre-wrap */
  .whitespace-pre-wrap {
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  /* Gradient boxes */
  .bg-gradient-to-r {
    background: linear-gradient(to right, var(--from-color, #f0f0f0), white) !important;
    -webkit-print-color-adjust: exact !important;
  }

  /* Specific color overrides for print */
  .from-emerald-50 { --from-color: #ecfdf5; }
  .from-blue-50 { --from-color: #eff6ff; }
  .from-amber-50 { --from-color: #fffbeb; }

  /* Prose text */
  .prose {
    font-size: 9pt;
    line-height: 1.5;
  }

  .prose-lg {
    font-size: 10pt;
  }

  .prose-sm {
    font-size: 8pt;
  }
}
