/* ==========================================================================
   Certificate Generator - Stylesheet
   ========================================================================== */

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --border: #d1d8e0;
  --text: #1a2028;
  --text-dim: #6b7785;
  --accent: #2d7a4a;
  --accent-2: #1f5a35;
  --gold: #c9a449;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #ca8a04;
}

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

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ==========================================================================
   Header
   ========================================================================== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo { display: flex; align-items: center; gap: 14px; }

.logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.logo h1 { font-size: 19px; font-weight: 700; }
.logo p { font-size: 12px; color: var(--text-dim); }

/* ==========================================================================
   Layout
   ========================================================================== */
.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .steps-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Panels
   ========================================================================== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  width: 26px; height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

.panel-header h2 { font-size: 15px; font-weight: 700; }
.panel-body { padding: 20px; }

.section { margin-bottom: 18px; }
.section:last-child { margin-bottom: 0; }

/* ==========================================================================
   Form Elements
   ========================================================================== */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-dim);
}

input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 70px; }

input[type="file"] { display: none; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* File drop zones */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.file-drop:hover { border-color: var(--accent); background: rgba(45,122,74,0.05); }
.file-drop.has-file { border-color: var(--success); border-style: solid; background: rgba(74,222,128,0.05); }
.file-drop .icon { font-size: 28px; margin-bottom: 6px; }
.file-drop .main { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.file-drop .sub { font-size: 11px; color: var(--text-dim); }

.file-drop-small { padding: 14px; }
.file-drop-small .icon { font-size: 22px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover:not(:disabled) { background: var(--accent-2); transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-row { display: flex; gap: 8px; }
.small-btn { padding: 8px 14px; width: auto; font-size: 13px; }

/* ==========================================================================
   Preview Area
   ========================================================================== */
.preview-wrap {
  padding: 24px;
  background: repeating-linear-gradient(
    45deg,
    #e8edf2,
    #e8edf2 10px,
    #f0f3f7 10px,
    #f0f3f7 11px
  );
  overflow: auto;
}

.canvas-container {
  background: white;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  max-width: 1000px;
  height: auto;
}

.toolbar {
  background: var(--surface);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar .spacer { flex: 1; }

.stat {
  background: var(--surface-2);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.stat strong { color: var(--text); font-weight: 700; }

/* ==========================================================================
   Recipients List
   ========================================================================== */
.recipient-list {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.recipient-item {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.recipient-item:last-child { border-bottom: none; }
.recipient-item:hover { background: var(--surface); }
.recipient-item.active {
  background: rgba(45,122,74,0.15);
  border-right: 3px solid var(--accent);
}
.recipient-info { flex: 1; min-width: 0; }
.recipient-name { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.recipient-email {
  font-size: 11px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  direction: ltr; text-align: right;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.sent { background: var(--success); }
.status-dot.failed { background: var(--error); }
.status-dot.sending { background: var(--warning); animation: pulse 1s infinite; }

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

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  transition: transform 0.3s;
  z-index: 1000;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}
.modal-bg.show { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }

.close-btn {
  background: none; border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-body { padding: 20px; }

.info-box {
  background: rgba(45,122,74,0.1);
  border: 1px solid rgba(45,122,74,0.3);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.7;
}
.info-box code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}

/* ==========================================================================
   Mapping Fields
   ========================================================================== */
.field-mapping {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.field-label { font-size: 13px; color: var(--text-dim); }

/* ==========================================================================
   Progress Bar
   ========================================================================== */
.progress-wrap {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  width: 0%;
  transition: width 0.3s;
}
.progress-text {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   Misc
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: 0.4; }

details {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 10px;
}
summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}
details[open] summary { margin-bottom: 10px; color: var(--text); }

.logo-preview {
  margin-top: 8px;
  height: 50px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.logo-preview img { max-height: 100%; max-width: 100%; }
.logo-preview .empty-text { font-size: 11px; color: var(--text-dim); }

.logo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.logo-grid > div { font-size: 11px; }

@media (max-width: 600px) {
  .logo-grid { grid-template-columns: repeat(2, 1fr); }
}

.help-text {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.5;
}

/* ==========================================================================
   Radio Group
   ========================================================================== */
.radio-group {
  display: flex;
  gap: 8px;
}

.radio-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
  margin-bottom: 0;
}

.radio-option:hover {
  border-color: var(--accent);
}

.radio-option input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.radio-option:has(input:checked) {
  background: rgba(45, 122, 74, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

/* ==========================================================================
   Archive
   ========================================================================== */
.archive-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.archive-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.archive-item-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.archive-item-header:hover { background: var(--bg); }

.archive-event-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.archive-event-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.archive-details {
  border-top: 1px solid var(--border);
  padding: 8px;
  background: var(--surface);
}

.archive-recipient {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.archive-recipient:last-child { border-bottom: none; }

.btn-danger {
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-family: 'Tajawal', sans-serif;
  font-size: 13px;
  cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }
