/* ===========================
   Design Tokens
=========================== */
:root{
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;

  --primary: #4CAF50;
  --primary-600:#45a049;

  --blue: #008CBA;
  --blue-600:#007bb5;

  --orange: #ff9800;
  --orange-600:#e08800;

  --red: #f44336;
  --red-600:#e53935;

  --violet:#6c63ff;
  --violet-600:#5a53e6;

  --shadow: 0 6px 18px rgba(0,0,0,.06);
  --radius: 10px;
}

/* ===========================
   Base
=========================== */
*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji", "Segoe UI Symbol";
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

/* ===========================
   Header + Logout
=========================== */
header{
  position: relative;
  background: var(--primary);
  color:#fff;
  padding: 18px 16px;
  text-align:center;
  box-shadow: var(--shadow);
}

header h1{
  margin:0;
  font-weight: 700;
  letter-spacing:.2px;
}

.logout-button{
  position:absolute;
  right:16px;
  top:50%;
  transform: translateY(-50%);
  display:inline-block;
  padding:8px 12px;
  border-radius:8px;
  background: var(--red);
  color:#fff;
  text-decoration:none;
  font-size:14px;
  transition:.2s ease-in-out;
}
.logout-button:hover{ background: var(--red-600); }

/* ===========================
   Layout Containers
=========================== */
.container{
  max-width:1100px;
  margin: 24px auto;
  padding: 0 16px;
}

.card{
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ===========================
   Messages (alerts)
=========================== */
.message{
  padding:12px 14px;
  border-radius:8px;
  margin: 0 0 16px 0;
  font-weight:600;
  box-shadow: var(--shadow);
}
.message.success{ background:#eaf7ec; color:#106d1c; border:1px solid #cfead3; }
.message.error{ background:#fdeaea; color:#9a1a12; border:1px solid #f7c4c1; }

/* ===========================
   Add Campaign Button
=========================== */
.add-campaign-btn{
  display:flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.add-campaign-button{
  background: var(--primary);
  color:#fff;
  text-decoration:none;
  border:none;
  border-radius:8px;
  padding:10px 14px;
  font-size:14px;
  font-weight:600;
  box-shadow: var(--shadow);
  transition: .2s ease-in-out;
}
.add-campaign-button:hover{ background: var(--primary-600); }

/* ===========================
   Tables (list_campaigns)
=========================== */
.campaigns-table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  overflow:hidden;
  box-shadow: var(--shadow);
}

.campaigns-table th,
.campaigns-table td{
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  vertical-align: middle;
}

.campaigns-table thead th{
  background:#f8fafc;
  color:#374151;
  text-align:left;
  font-weight:700;
  font-size:14px;
}

.campaigns-table tbody tr:hover{
  background:#fafbfd;
}

.thumbnail-image{
  width:68px;
  height:68px;
  object-fit:cover;
  border-radius:8px;
  border:1px solid var(--border);
  cursor:pointer;
}

/* Inline muted info */
.muted{
  color: var(--muted);
  font-size:12px;
  margin-top:4px;
}

/* ===========================
   Action Buttons (row)
=========================== */
.action-buttons{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap: wrap;
}

.process-button,
.send-button,
.delete-button,
.edit-button,
.show-button{
  display:inline-block;
  padding:7px 11px;
  font-size:12px;
  border:none;
  border-radius:8px;
  color:#fff;
  text-decoration:none;
  font-weight:700;
  letter-spacing:.2px;
  box-shadow: var(--shadow);
  transition: transform .06s ease, opacity .2s ease;
  will-change: transform;
}
.process-button:active,
.send-button:active,
.delete-button:active,
.edit-button:active,
.show-button:active{
  transform: translateY(1px);
}

/* Individual colors */
.process-button{ background: var(--red); }
.process-button.processed{ background:#388e3c; } /* green after success */
.send-button{ background: var(--blue); }
.delete-button{ background: var(--red); }
.edit-button{ background: var(--violet); }
.show-button{ background: var(--orange); }

/* Hovers */
.process-button:hover{ opacity:.92; }
.send-button:hover{ background: var(--blue-600); }
.delete-button:hover{ background: var(--red-600); }
.edit-button:hover{ background: var(--violet-600); }
.show-button:hover{ background: var(--orange-600); }

/* Keep buttons from overlapping in tight cells */
.campaigns-table td:last-child{
  min-width:220px;
}

/* ===========================
   Forms (upload, edit, login)
=========================== */
.upload-form,
.login-container form,
.edit-form{
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:18px;
  box-shadow: var(--shadow);
}

.form-row{
  display:flex;
  flex-direction: column;
  gap:8px;
  margin-bottom:14px;
}
.form-row label{
  font-weight:700;
  font-size:14px;
}
.form-row input[type="text"],
.form-row input[type="date"],
.form-row input[type="password"],
.form-row input[type="file"],
.login-container input[type="text"],
.login-container input[type="password"],
textarea{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:8px;
  background:#fff;
  font-size:14px;
  outline:none;
}
textarea{
  min-height:220px;
  resize:vertical;
}

.file-hint{
  color: var(--muted);
  font-size:12px;
  margin-top:2px;
}

.button-group{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.submit-button{
  background: var(--primary);
  color:#fff;
  border:none;
  border-radius:8px;
  padding:10px 14px;
  font-size:14px;
  font-weight:700;
  box-shadow: var(--shadow);
  cursor:pointer;
  transition:.2s ease-in-out;
}
.submit-button:hover{ background: var(--primary-600); }

.cancel-button{
  display:inline-block;
  background: var(--red);
  color:#fff;
  text-decoration:none;
  padding:10px 14px;
  border-radius:8px;
  font-size:14px;
  box-shadow: var(--shadow);
  transition:.2s ease-in-out;
}
.cancel-button:hover{ background: var(--red-600); }

/* Login */
.login-container{
  max-width:420px;
  margin: 40px auto;
  padding: 0 16px;
}
.login-container h2{
  text-align:center;
  margin:0 0 14px 0;
}

/* ===========================
   Image Popup (in-page modal)
=========================== */
.image-popup{
  display:none;             /* show via JS */
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
  padding: 24px;
}
.image-popup .popup-content{
  background:#111827;
  color:#fff;
  width:min(92vw, 1000px);
  max-height: 92vh;
  margin: 0 auto;
  border-radius: 12px;
  padding: 16px;
  overflow:auto;
  box-shadow: var(--shadow);
  position: relative;
}
.image-popup img{
  display:block;
  max-width: 100%;
  max-height: 80vh; /* keep controls visible */
  margin: 0 auto;
  border-radius: 8px;
}
.image-popup .metadata{
  text-align:center;
  color:#e5e7eb;
  margin-top:10px;
  font-size:14px;
}
.close-popup{
  position:absolute;
  right:12px;
  top:12px;
  background:#374151;
  color:#fff;
  border:none;
  border-radius:8px;
  padding:6px 10px;
  font-size:12px;
  cursor:pointer;
}
.close-popup:hover{ background:#4b5563; }

/* ===========================
   Utility
=========================== */
.hidden{ display:none !important; }
.center{ text-align:center; }

/* ===========================
   Responsive
=========================== */
@media (max-width: 800px){
  .campaigns-table td:nth-child(3),
  .campaigns-table th:nth-child(3){
    min-width:220px;
  }
  .action-buttons{ gap:6px; }
  .campaigns-table td:last-child{ min-width: 200px; }
}
@media (max-width: 560px){
  header{ padding: 14px 12px; }
  .logout-button{ right:10px; padding:7px 10px; }
  .thumbnail-image{ width:56px; height:56px; }
  .process-button, .send-button, .delete-button, .edit-button, .show-button{
    padding:6px 9px; font-size:11px;
  }
}
