/**
 * CHM Solar - Styles globaux
 * Générateur de rapports photovoltaïques
 */

:root {
  /* Couleurs principales */
  --primary: #0055A4;
  --primary-600: #0B63B8;
  --primary-700: #004080;
  --primary-100: #E8F1FF;
  --primary-50: #F5F9FF;

  /* Couleurs secondaires */
  --accent: #4CAF50;
  --accent-light: #E8F5E9;
  --warning: #FF9800;
  --warning-light: #FFF3E0;
  --danger: #D32F2F;
  --danger-light: #FFEBEE;
  --info: #2196F3;
  --info-light: #E3F2FD;

  /* Textes */
  --ink: #1a1a2e;
  --ink-light: #4a4a68;
  --ink-muted: #6b7280;

  /* Backgrounds */
  --bg-body: #f5f7fa;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;

  /* Ombres */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.12);
  --shadow-primary: 0 4px 14px rgba(0, 85, 164, 0.25);

  /* Rayons */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p { margin-bottom: 1rem; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-700);
}

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.card-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-100);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: white;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 85, 164, 0.35);
  color: white;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--primary-100);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent) 0%, #43A047 100%);
  color: white;
}

.btn-success:hover {
  transform: translateY(-2px);
}

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

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1rem;
}

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

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.form-label .required {
  color: var(--danger);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--bg-card);
  border: 2px solid #e5e7eb;
  border-radius: var(--radius);
  transition: var(--transition);
}

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

.form-input::placeholder {
  color: var(--ink-muted);
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  margin-top: 0.375rem;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--danger);
  margin-top: 0.375rem;
}

/* Form Grid */
.form-row {
  display: grid;
  gap: 1rem;
}

.form-row-2 { grid-template-columns: repeat(2, 1fr); }
.form-row-3 { grid-template-columns: repeat(3, 1fr); }
.form-row-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .form-row-2,
  .form-row-3,
  .form-row-4 {
    grid-template-columns: 1fr;
  }
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-check-label {
  font-size: 0.9375rem;
  color: var(--ink);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
}

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

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

.badge-warning {
  background: var(--warning-light);
  color: #E65100;
}

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

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid #e5e7eb;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--primary-50);
}

th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

tbody tr:hover {
  background: var(--bg-hover);
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 100%);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--ink-light);
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 0.25rem;
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.alert-info {
  background: var(--info-light);
  border-left: 4px solid var(--info);
  color: #0D47A1;
}

.alert-success {
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  color: #1B5E20;
}

.alert-warning {
  background: var(--warning-light);
  border-left: 4px solid var(--warning);
  color: #E65100;
}

.alert-danger {
  background: var(--danger-light);
  border-left: 4px solid var(--danger);
  color: #B71C1C;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

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

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-muted);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--ink);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e5e7eb;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--primary-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state-text {
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

/* Utilities */
.text-primary { color: var(--primary); }
.text-success { color: var(--accent); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--ink-muted); }

.bg-primary { background: var(--primary); color: white; }
.bg-success { background: var(--accent); color: white; }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 640px) {
  html { font-size: 14px; }

  .container { padding: 0 1rem; }

  .card { padding: 1rem; }

  .btn { padding: 0.625rem 1.25rem; }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
