/* ========== Design tokens ========== */
/* Base styles for the application */

:root{
  --bg:#FAFAFA;
  --card:#FFFFFF;
  --text:#140600;
  --muted:#8A8A8A;
  --border:rgba(20,6,0,0.16);
  --accent:#FA682E;
  --accent-600:#e55f2a;
  --accent-700:#cc5525;
  --ring:rgba(250,104,46,0.45);
  --shadow:0 12px 40px rgba(0,0,0,0.18);
  --radius-lg:32px;
  --radius-md:16px;
  --radius-sm:8px;
  /* Container width variables */
  --container-width-sm:480px;
  --container-width-md:800px;
  --container-width-lg:900px;
}

/* ========== Base ========== */
*{box-sizing:border-box}
body{
  margin:0;
 /* background:linear-gradient(180deg,#fff 0%, #fff 65%, #fff6f1 100%);
  background-size: cover;
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;*/
  color:var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

/* ========== Container (responsive) ========== */
.container{
  background:var(--card);
  border-radius:var(--radius-lg);
  padding:24px;
  width:min(var(--container-width-md), 90%);
  margin:32px auto;
  box-shadow:var(--shadow);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:12px;
}

/* Logo */
.logo-container{ text-align:center; margin-bottom:0 }
.logo-img{ width:140px; height:auto; margin-bottom:4px }

/* Title */
.main-title{
  width:min(720px, 95%);
  text-align:center;
  font-size:clamp(1.1rem, 1.2rem + 0.6vw, 1.6rem);
  color:var(--text);
  margin:0 0 4px 0;
  line-height:1.3;
  font-weight:700;
}

/* Dropzone */
.drop-zone{
  border:1px dashed #d8d8d8;
  border-radius:var(--radius-md);
  padding:48px 20px;
  background:var(--bg);
  margin:8px auto 0;
  transition:border-color .25s ease, box-shadow .25s ease, transform .08s ease;
  text-align:center;
  width:100%;
  max-width:720px;
  cursor:pointer;
  outline:0;
}
.drop-zone:focus-visible{
  box-shadow:0 0 0 4px var(--ring);
  border-color:var(--accent);
}
.drop-zone.is-hover,
.drop-zone.is-dragover,
.drop-zone.dragover{
  border-color:var(--accent);
  box-shadow:0 0 0 4px var(--ring);
}
.upload-icon-svg{ width:40px; height:40px; margin-bottom:8px; opacity:.6 }
.drop-zone-content{
  pointer-events:none;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
}
.upload-text{ font-size:1em; color:var(--text); font-weight:600 }
.upload-hint{ font-size:.9em; color:var(--muted) }

/* Drop zone valid state */
.drop-zone.is-valid{
  border-color: #21a67a !important;
  margin-bottom: 4px;
  box-shadow: 0 0 0 4px rgba(33,166,122,0.35);
  background: #f3fbf8;
}

/* ====== Resize settings (grid responsive & clean) ====== */
.resize-settings{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:12px;
  margin:24px 0 0;
  width:100%;
  max-width:720px;
}
.resize-block{
  background:var(--bg);
  border:1px solid #fba785;
  border-radius:var(--radius-sm);
  padding:10px;
  display:flex; flex-direction:column; align-items:center; gap:8px;
}
.resize-block h3{
  font-size:14px; color:var(--text); margin:0;
}
.resize-block input[type="number"]{
  width:100px!important;
  padding:8px 10px;
  font-size:14px;
  border-radius:6px;
  border:1px solid #d4d4d4;
  text-align:center;
  background:#fff;
  color:var(--text);
  transition:border-color 0.2s ease, box-shadow 0.2s ease;
  outline:none;
}

.resize-block input[type="number"]:hover{
  border-color:var(--accent);
}

.resize-block input[type="number"]:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px var(--ring);
}

.image-wrapper{
  width:112px; height:72px;
  display:flex; align-items:center; justify-content:center;
  background:#fff; border:1px solid #eee; border-radius:6px;
}
.image-wrapper img{
  max-width:100%; max-height:100%; object-fit:contain; border-radius:4px;
}
.resize-block p{ font-size:12px; color:#777; margin:0 }

/* Features list */
.features-list{
  padding:16px;
  background:var(--bg);
  border-radius:var(--radius-md);
  border:1px solid var(--border);
  width:100%;
  max-width:720px;
  margin-top:24px;
}
.features-list ul{
  list-style:none; padding:0; margin:0;
  display:flex; flex-direction:column; gap:10px;
}
.features-list li{
  font-size:14px;
  display:flex; align-items:center; gap:10px;
  color:var(--text);
}
.features-list img{ width:14px; height:14px; opacity:.9 }

/* Legal links */
.legal-links{
  display:flex; align-items:center; justify-content:center; gap:8px;
  margin-top:12px; flex-wrap:wrap;
}
.legal-links a{
  color:var(--text);
  font-size:12px;
  text-decoration:underline;
  transition:opacity .2s ease;
}
.legal-links a:hover{ opacity:.7 }

/* CTA and action buttons */
.optimize-btn, #downloadBtn{
  width:100%;
  max-width:720px;
  padding:12px 32px;
  font-size:16px; font-weight:700;
  background:var(--accent);
  color:#fff; border:0; border-radius:var(--radius-sm);
  cursor:pointer; transition:transform .04s ease, background-color .2s ease, box-shadow .2s ease;
  box-shadow:0 6px 16px rgba(250,104,46,0.25);
}
.optimize-btn:hover, #downloadBtn:hover{ background:var(--accent-600) }
.optimize-btn:active, #downloadBtn:active{ transform:translateY(1px); background:var(--accent-700) }
.optimize-btn:focus-visible, #downloadBtn:focus-visible{ outline:none; box-shadow:0 0 0 4px var(--ring) }

/* Enhanced file info display */
.file-info { 
  display: none; 
  margin: 16px 0; 
  padding: 16px; 
  background: #e3f2fd; 
  border-radius: var(--radius-md); 
  color: #1976d2;
  border: 1px solid #90caf9;
  max-width: 720px;
  width: 100%;
}

/* Status messages with new design */
.status-container {
  width: 100%; 
  max-width: 720px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: none; /* Initially hidden */
}

.status { 
  padding: 16px; 
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
  width: 100%;
  cursor: pointer;
  user-select: none;
}

.status:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

#statusText {
  flex: 1;
  line-height: 1.5;
}

.status.expanded {
  border-bottom: 1px solid var(--border);
}

.status-container.success .status { 
  background: #f3fbf8; 
  color: #155724; 
}

.status-container.success .status:hover { 
  background: #e8f5e8; 
}

.status-container.error .status { 
  background: #fef5f5; 
  color: #721c24; 
}

.status-container.error .status:hover { 
  background: #f5e5e5; 
}

.status-container.processing .status { 
  background: #f0f9ff; 
  color: #0c5460; 
}

.status-container.processing .status:hover { 
  background: #e0f2fe; 
}

.expand-arrow {
  font-size: 14px;
  transition: transform 0.3s ease;
  margin-left: 10px;
  color: var(--muted);
  cursor: pointer;
  display: inline-block; /* Always visible when status container is shown */
  user-select: none;
}

.expand-arrow.collapsed {
  transform: rotate(-90deg);
}

.expand-arrow.expanded {
  transform: rotate(0deg);
}

.processing-details {
  background: #fafbfc;
  border-top: 1px solid var(--border);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  display: none; /* Collapsed by default */
  transition: all 0.3s ease;
}

.processing-images-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.no-images {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 20px;
}

.image-processing-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.image-processing-item.completed {
  border-color: #21a67a;
  background: #f3fbf8;
}

.image-processing-item.completed.too-small {
  border-color: #d97706;
  background: #fef3e2;
}

.image-processing-item.processing {
  border-color: #0ea5e9;
  background: #f0f9ff;
  animation: pulse 2s infinite;
}

.image-processing-item.analyzing {
  border-color: #f59e0b;
  background: #fffbeb;
}

.image-processing-item.error {
  border-color: #d64545;
  background: #fef5f5;
}

.image-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.image-preview {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-placeholder {
  font-size: 16px;
  color: var(--muted);
}

.image-details {
  flex: 1;
}

.filename-change {
  font-weight: 500;
  margin-bottom: 4px;
}

.original-name {
  color: var(--muted);
}

.arrow {
  margin: 0 8px;
  color: var(--muted);
}

.new-name {
  color: var(--text);
}

.image-description {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
  font-style: italic;
  line-height: 1.3;
  max-width: 300px;
}

.image-dimensions {
  font-size: 11px;
  color: var(--muted);
}

.processing-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* User info pills preserved but updated styling */
.user-info { 
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  margin-bottom: 8px; width: 90%;
}
.user-info-left {
  display: flex; align-items: center; gap: 8px;
}
.user-info-right {
  display: flex; align-items: center; gap: 8px;
}
.credits-display { 
  background: transparent; 
  color: var(--text); padding: 6px 12px; border-radius: 20px; 
  font-size: 16px; font-weight: 600; margin-right: 0; 
}
.buy-credits-btn { 
  background: var(--accent); color: white; border: none; 
  padding: 8px 16px; border-radius: 38px; cursor: pointer; 
  font-size: 12px; transition: background 0.3s ease; 
  text-decoration: none; display: inline-block; line-height: 1; font-weight: 600;
}
.buy-credits-btn:hover { background: var(--accent-600); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #ddd; }
.user-name { color: var(--text); font-weight: 500; font-size: 13px; }
.logout-btn { 
  background: transparent; border: none; 
  padding: 6px 8px; border-radius: px; cursor: pointer; 
  transition: background 0.3s ease; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.logout-btn:hover { 
  background: var(--bg); 
}
.logout-btn img {
  width: 16px; height: 16px;
}

/* Runtime UI elements preserved from old stylesheet */
.file-info { display: none; margin: 20px 0; padding: 15px; background: #e3f2fd; border-radius: 8px; color: #1976d2; }
.progress { display: none; margin: 20px 0; width: 95%; }
.progress-bar { width: 100%; height: 12px; background: #eee; border-radius: 6px; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
.progress-fill { height: 100%; background: linear-gradient(90deg, #fa682e, #fba785); width: 0%; transition: width 0.5s ease; animation: pulse 2s infinite; }

/* Enhanced progress details */
.progress-details {
    margin-top: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    font-size: 0.9rem;
    line-height: 1.4;
}

.progress-files {
    font-weight: 600;
    color: #495057;
    margin-bottom: 6px;
}

.progress-time {
    color: #6c757d;
    margin-bottom: 4px;
}

.progress-ai {
    color: #28a745;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.progress-description {
    color: #6f42c1;
    font-size: 0.9rem;
    margin-bottom: 6px;
    font-style: italic;
    line-height: 1.3;
    max-width: 100%;
    word-wrap: break-word;
}

.progress-recent {
    color: #17a2b8;
    font-size: 0.85rem;
    margin-top: 6px;
    font-style: italic;
}

/* Processing active state */
.progress.processing-active .progress-fill {
    background: linear-gradient(90deg, #fa682e, #fb7742, #fba785);
    background-size: 200% 100%;
    animation: progressWave 2s linear infinite, pulse 2s infinite;
}

@keyframes progressWave {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.7;} }

/* Notifications preserved */
.notification-popup { position: fixed; top: 20px; right: 20px; z-index: 10000; opacity: 0; visibility: hidden; transition: all 0.3s ease; max-width: 400px; }
.notification-popup.notification-popup-show { opacity: 1; visibility: visible; }
.notification-popup-content { background: white; border-radius: 12px; box-shadow: 0 15px 35px rgba(0,0,0,0.2); overflow: hidden; border-left: 5px solid #28a745; transform: translateX(100%); transition: transform 0.3s ease; }
.notification-popup-show .notification-popup-content { transform: translateX(0); }
.notification-popup-header { padding: 15px 20px 10px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; }
.notification-popup-header h3 { margin: 0; font-size: 1.1em; color: #28a745; }
.notification-popup-close { background: none; border: none; font-size: 1.5em; cursor: pointer; color: #999; padding: 0; width: 25px; height: 25px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: all 0.3s ease; }
.notification-popup-close:hover { background: #f0f0f0; color: #666; }
.notification-popup-body { padding: 15px 20px 20px; }
.notification-popup-body p { margin: 0; font-size: 1em; line-height: 1.5; color: #555; }
.notification-popup-success .notification-popup-content { border-left-color: #28a745; }
.notification-popup-success .notification-popup-header h3 { color: #28a745; }
.notification-popup-warning .notification-popup-content { border-left-color: #ffc107; }
.notification-popup-warning .notification-popup-header h3 { color: #ffc107; }
.notification-popup-error .notification-popup-content { border-left-color: #dc3545; }
.notification-popup-error .notification-popup-header h3 { color: #dc3545; }
/* ====== Responsive ====== */
@media (max-width: 1024px){
  .container{ width:min(860px, 94%); padding:22px }
}
@media (max-width: 768px){
  .container{ width:94%; padding:18px; margin:24px auto }
  .resize-settings{ grid-template-columns: repeat(2, minmax(0,1fr)) }
}
@media (max-width: 520px){
  .main-title{ width:100% }
  .drop-zone{ max-width:100%; padding:36px 16px }
  .resize-settings{ grid-template-columns: 1fr }
  .image-wrapper{ width:100%; height:120px }
}

/* Motion safe */
@media (prefers-reduced-motion: reduce){
  .drop-zone, .optimize-btn, #downloadBtn{ transition:none }
}

/* Hide native file input; interaction via drop zone */
#fileInput { display: none; }

/* ===== Overlay loader ===== */
.overlay{
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.overlay.is-visible{ display:flex }
.overlay-box{
  background: #fff;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  display: flex; align-items: center; gap: 14px;
  min-width: 280px;
  border: 1px solid rgba(20,6,0,0.08);
}
.spinner{
  width: 28px; height: 28px;
  border: 3px solid #eee;
  border-top-color: #FA682E;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg) } }
.overlay-text{ display:flex; flex-direction:column; gap:4px; color:#140600; font-size:14px }

/* ===== Toaster ===== */
.toast-stack{
  position: fixed;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 10000;
}
.toast{
  display:flex; align-items:flex-start; gap:10px;
  background:#fff;
  border:1px solid rgba(20,6,0,0.12);
  border-left-width:4px;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.14);
  max-width: 360px;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in{
  from{ transform: translateY(6px); opacity:0 }
  to{ transform: translateY(0); opacity:1 }
}
.toast .title{ font-weight:700; font-size:14px; color:#140600; margin-bottom:2px }
.toast .msg{ font-size:13px; color:#525252 }
.toast.success{ border-left-color:#21a67a }
.toast.error{ border-left-color:#d64545 }
.toast .close{
  margin-left:auto; background:none; border:0; cursor:pointer; font-size:16px; line-height:1;
  color:#8a8a8a;
}
.toast .close:hover{ color:#140600 }

/* ===== Inline field error ===== */
.field-error{
  margin-top:6px; font-size:12px; color:#d64545;
}


/* Force le background pattern sur la page index */
body {
  /* vars */
  --s: 200px;                /* taille du motif */
  --c1: #FA682E;             /* orange */
  --c2: #140600;             /* noir profond */

  --_g: var(--c2) 4% 14%, var(--c1) 14% 24%, var(--c2) 22% 34%,
        var(--c1) 34% 44%, var(--c2) 44% 56%, var(--c1) 56% 66%,
        var(--c2) 66% 76%, var(--c1) 76% 86%, var(--c2) 86% 96%;

  /* reset + apply */
  background: radial-gradient(100% 100% at 100% 0, var(--c1) 4%, var(--_g), #0008 96%, #0000),
              radial-gradient(100% 100% at 0 100%, #0000, #0008 4%, var(--_g), var(--c1) 96%) var(--c1) !important;
  background-size: var(--s) var(--s) !important;
}

/* Hover = même style que les inputs en :focus */
.drop-zone:hover,
.drop-zone:focus-within {
  border-color: var(--accent) !important;     /* #FA682E */
  box-shadow: 0 0 0 3px var(--ring) !important;
  transform: translateY(-2px);
}

/* ===== Header responsive (mobile) ===== */
@media (max-width: 560px) {
  /* 2 lignes :
     1) logo à gauche  | avatar + logout à droite
     2) crédits à gauche | bouton upgrade à droite */
  .user-info {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 6px;
  }

  /* "Déplie" les enfants de .user-info-left pour les placer dans la grille */
  .user-info-left { display: contents; }

  /* Ligne 1 */
  .logo-container { grid-column: 1; grid-row: 1; }
  .user-info-right { grid-column: 2; grid-row: 1; justify-self: end; }

  /* Ligne 2 */
  .credits-display { grid-column: 1; grid-row: 2; }
  .buy-credits-btn { grid-column: 2; grid-row: 2; justify-self: end; }

  /* Ajustements UI */
  .logo-img { width: 120px; }
  .user-name { display: none; }               /* évite la casse sur petit écran */
  .buy-credits-btn { padding: 8px 12px; }     /* bouton plus compact */
}
