/* ===== Variables ===== */
:root {
  --gray: #494B4C;
  --yellow: #F4D819;
  --blue: #0A66C2;
  --bg: #F8F9FA;
  --white: #FFFFFF;
  --border: #E5E7EB;
  --text: #1F2937;
  --text-light: #6B7280;
  --danger: #EF4444;
  --success: #10B981;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

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

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

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--gray);
  color: var(--white);
}

.logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--yellow);
  letter-spacing: 1px;
}

.header-logo {
  height: 32px;
  width: auto;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.1);
}

/* ===== Screens ===== */
.screen {
  display: none;
  padding: 16px;
  padding-bottom: 100px;
  max-width: 600px;
  margin: 0 auto;
}

.screen.active {
  display: block;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.screen-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.btn-back:hover {
  background: var(--border);
}

/* ===== Typography ===== */
h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--gray);
}

h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(10,102,194,0.1);
}

textarea {
  resize: vertical;
}

select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* ===== Voice Input ===== */
.input-voice-wrap {
  position: relative;
}

.input-voice-wrap input,
.input-voice-wrap textarea {
  padding-right: 48px;
}

.btn-voice {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-voice:hover {
  background: var(--border);
}

.btn-voice.recording {
  background: var(--danger);
  color: var(--white);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ===== Buttons ===== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--yellow);
  color: var(--gray);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 24px;
}

.btn-primary:hover {
  background: #e5ca00;
  box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-block;
  padding: 10px 16px;
  background: var(--white);
  color: var(--blue);
  border: 1.5px solid var(--blue);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(10,102,194,0.05);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}

.btn-add {
  padding: 10px 16px;
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add:hover {
  background: #084e96;
}

.btn-clear {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  margin-top: 8px;
}

/* ===== Search Results ===== */
.search-container {
  position: relative;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-result-item:hover {
  background: rgba(10,102,194,0.05);
}

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

.search-result-item .result-title {
  font-weight: 600;
  font-size: 14px;
}

.search-result-item .result-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ===== Client Card ===== */
.client-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--white);
  border: 1.5px solid var(--success);
  border-radius: var(--radius);
  margin-top: 8px;
}

.client-card.hidden {
  display: none;
}

.client-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.client-info strong {
  font-size: 15px;
}

.client-info span {
  font-size: 13px;
  color: var(--text-light);
}

/* ===== Demand Card ===== */
.demand-card {
  padding: 14px;
  background: rgba(10,102,194,0.05);
  border: 1px solid rgba(10,102,194,0.15);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.demand-card.hidden {
  display: none;
}

.demand-card p {
  font-size: 14px;
  line-height: 1.5;
  margin-top: 6px;
  white-space: pre-wrap;
}

/* ===== Project List ===== */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.project-list.hidden {
  display: none;
}

.project-item {
  padding: 12px 14px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.project-item:hover,
.project-item.selected {
  border-color: var(--blue);
  background: rgba(10,102,194,0.03);
}

.project-item.selected {
  border-width: 2px;
}

.project-item .project-title {
  font-weight: 600;
  font-size: 14px;
}

.project-item .project-status {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ===== Postes List ===== */
.postes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.poste-card {
  padding: 14px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.poste-card:hover {
  border-color: var(--blue);
}

.poste-card-info {
  flex: 1;
}

.poste-card-info .poste-name {
  font-weight: 600;
  font-size: 15px;
}

.poste-card-info .poste-details {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
  display: flex;
  gap: 12px;
}

.poste-card-info .poste-details span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.poste-card-actions {
  display: flex;
  gap: 4px;
}

.btn-delete-poste {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  font-size: 18px;
}

/* ===== Photos ===== */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--white);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-light);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-photo:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* ===== Fournitures ===== */
.fournitures-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.fourniture-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.fourniture-item .fourniture-ref {
  font-weight: 600;
  color: var(--blue);
}

.fourniture-item .fourniture-name {
  flex: 1;
  margin-left: 8px;
}

.fourniture-item .fourniture-qty {
  width: 50px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  margin: 0 8px;
}

.fourniture-item .btn-remove-fourniture {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--gray);
  color: var(--white);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

/* ===== Loading ===== */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading p {
  color: var(--white);
  margin-top: 16px;
  font-weight: 500;
}

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

/* ===== Mobile adjustments ===== */
@media (max-width: 400px) {
  .photos-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
