/**
 * CRM MAINTENANCE V3 - STYLES
 * Mobile-first, responsive, moderne
 */

/* ============================================
   VARIABLES & RESET
   ============================================ */
:root {
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --secondary: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 260px;
  --header-height: 64px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   HEADER
   ============================================ */
.crm-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--primary);
  margin: 0;
}

.user-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-email {
  font-size: 0.875rem;
  color: var(--gray-600);
  display: none;
}

@media (min-width: 768px) {
  .user-email {
    display: inline;
  }
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

/* ============================================
   CONTAINER & SIDEBAR
   ============================================ */
.crm-container {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

.crm-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: white;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  padding: 1rem 0;
  z-index: 90;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--gray-700);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item .icon {
  font-size: 1.25rem;
}

.nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.nav-item.active {
  background: var(--primary);
  color: white;
}

.nav-item.nav-secondary {
  opacity: 0.6;
  font-style: italic;
}

.sidebar-divider {
  margin: 1rem 0;
  border: none;
  border-top: 1px solid var(--gray-200);
}

.sidebar-status {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--gray-200);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--success);
  color: white;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
}

.sync-status.offline {
  background: var(--warning);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.crm-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  max-width: 1400px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .crm-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  
  .crm-main {
    margin-left: 0;
    padding: 1rem;
  }
}

/* ============================================
   DASHBOARD COMPONENTS
   ============================================ */
.dashboard-header {
  margin-bottom: 2rem;
}

.dashboard-header h2 {
  font-size: 2rem;
  font-weight: 900;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 1rem;
  color: var(--gray-600);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-left: 4px solid var(--primary);
}

.stat-card.stat-success {
  border-left-color: var(--success);
}

.stat-card.stat-info {
  border-left-color: var(--info);
}

.stat-card.stat-warning {
  border-left-color: var(--warning);
}

.stat-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.stat-value {
  font-size: 2rem;
  font-weight: 900;
  color: var(--gray-900);
}

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

/* Dashboard Sections */
.dashboard-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.dashboard-section {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dashboard-section h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 1rem;
}

/* Interventions List */
.intervention-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.intervention-item:last-child {
  border-bottom: none;
}

.intervention-time {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 60px;
}

.intervention-details {
  flex: 1;
}

.intervention-client {
  font-weight: 600;
  color: var(--gray-900);
}

.intervention-type {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.intervention-status {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-planifie {
  background: var(--info);
  color: white;
}

.status-en_cours {
  background: var(--warning);
  color: white;
}

.status-terminee {
  background: var(--success);
  color: white;
}

/* Techniciens List */
.technicien-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.technicien-item:last-child {
  border-bottom: none;
}

.technicien-avatar {
  font-size: 2rem;
}

.technicien-info {
  flex: 1;
}

.technicien-name {
  font-weight: 600;
  color: var(--gray-900);
}

.technicien-status {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.technicien-time {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
}

/* ============================================
   TECHNICIEN DASHBOARD
   ============================================ */
.tech-stats {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tech-stat {
  text-align: center;
}

.tech-stat .stat-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--primary);
}

.tech-stat .stat-label {
  font-size: 0.875rem;
  color: var(--gray-600);
}

/* Intervention Cards */
.interventions-today {
  margin-bottom: 2rem;
}

.interventions-today h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.intervention-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.intervention-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.intervention-time {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
}

.intervention-body {
  margin-bottom: 1rem;
}

.client-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

.intervention-type,
.intervention-address {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.intervention-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-600);
  color: white;
}

.btn-secondary:hover {
  background: var(--gray-700);
}

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

.btn-info:hover {
  background: #0891b2;
}

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

.btn-block {
  width: 100%;
}

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

.dashboard-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.dashboard-actions .btn {
  flex: 1;
  min-width: 200px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}

.empty-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 1rem;
}

.placeholder-page {
  text-align: center;
  padding: 4rem 2rem;
}

.placeholder-icon {
  font-size: 5rem;
  margin-bottom: 1.5rem;
}

.placeholder-page h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.placeholder-page p {
  font-size: 1.125rem;
  color: var(--gray-600);
  margin-bottom: 2rem;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
  .crm-header h1 {
    font-size: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .dashboard-sections {
    grid-template-columns: 1fr;
  }
  
  .tech-stats {
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .dashboard-actions {
    flex-direction: column;
  }
  
  .dashboard-actions .btn {
    width: 100%;
  }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
  display: none !important;
}

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

.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; }
