/* AZDAT base + components (refactored from snippet) */
@layer tokens, base, components, utilities, overrides;

/* ==== Base (element-level) ==== */
@layer base {
  * { box-sizing: border-box; }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Arial, sans-serif);
  }
  a { color: inherit; text-decoration: none; }
  a:hover { color: var(--accent); }
}

@layer base {
  html { overflow-y: scroll; } /* Forces scrollbar, normalizes <html> width to ~1154px */
  body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Arial, sans-serif);
  }
}

@layer components {
  /* Card section headings (e.g., "Business Basics", "Business Type & Location") */
  .az-card > .section-title {
    font-size: clamp(1.125rem, 2vw, 1.375rem); /* bigger than labels */
    font-weight: 700;                           /* a notch bolder */
    color: #334155;                             /* slate-700 for contrast */
    line-height: 1.25;
    margin-bottom: 12px;                        /* a bit more breathing room */
  }
  .plan-description {
    font-size: 0.9rem;
    color: #618ED8;
    margin-bottom: 12px;
    line-height: 1.4;
  }

}

@layer components {
  .wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; } /* Updates padding to 16px */
  .az-container { max-width: var(--content-max); margin: 0 auto; padding: 0 16px; width: 100%; } /* Updates padding, adds width */
  .az-add { padding: 24px 0; min-height: calc(100vh - 100px); } /* Ensures height for overflow */
  .faq-row { width: 100%; max-width: 100%; box-sizing: border-box; margin-bottom: 16px; } /* Extends FAQ styling */
}

@layer components {
  /* Form caption contrast: clearer than body text, not shouty */
  .field label,
  .field-wrap label {
    color: #475569;        /* slate-600: distinct from input text */
    font-weight: 600;      /* slightly bolder than current 500 */
  }

  /* Make placeholders obviously “hint-text” instead of answers */
  input::placeholder,
  textarea::placeholder {
    color: #94a3b8;        /* slate-400 */
  }

  /* Optional (nice on bright backgrounds): give inputs a subtle fill */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  textarea {
    background: #f8fafc;   /* slate-50 */
  }
}

/* ==== Components (reusable classes) ==== */
@layer components {
  .section-title {
    font-weight: 600;
    margin: 0 0 8px;
  }

  .wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }
  .az-container { max-width: var(--content-max); margin: 0 auto; padding: 24px; }

  .az-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .az-back { font-size: 16px; color: #2563eb; }

  .az-title { margin: 0 0 0.5rem; font-size: clamp(1.5rem, 2.5vw, 2rem); }
  .badge { display: inline-block; background: #CCF9E8; border-radius: 999px; padding: 4px 10px; font-size: 12px; margin-left: 8px; }
  .az-sub { color: var(--muted); margin-bottom: 1rem; }

  .az-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    background: var(--card);
    margin-bottom: 24px; /* Increased for better separation */
  }

  .hint { color: #64748b; font-size: 13px; margin-bottom: 8px; }

  .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
  .chip {
    background: #f3f4f6;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .chip button { border: none; background: none; cursor: pointer; font-size: 14px; }

  .actions { display: flex; gap: 10px; margin-top: 16px; }

  .az-btn {
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
  }
  .az-btn:disabled { background: #d1d5db; cursor: not-allowed; }
  .az-btn.ghost { background: #f3f4f6; color: #111827; }

  .az-err {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 10px;
    margin: 8px 0;
  }
  .az-ok {
    background: #ecfeff;
    color: #164e63;
    border: 1px solid #a5f3fc;
    border-radius: 10px;
    padding: 10px;
    margin: 8px 0;
  }

  .input-wrap { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; max-width: var(--form-max); }
  .input-wrap input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
  }
  .input-wrap input:focus { outline: none; border-color: var(--brand); }

  .field-wrap { max-width: var(--form-max); margin-bottom: 12px; }
  .field-wrap select, .field-wrap input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
  }
  .field-wrap select:focus, .field-wrap input:focus { outline: none; border-color: var(--brand); }

  .char-count { font-size: 12px; color: var(--muted); margin: 8px 0; text-align: left; }

  .help-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    cursor: pointer;
    font-size: 12px;
    margin-left: 6px;
  }
  .help-icon:hover { background: #cbd5e1; }

  .help-text {
    display: none;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    font-size: 13px;
    color: #374151;
  }
  .help-text.show { display: block; }

  .mode-card {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    cursor: pointer;
    margin-bottom: 8px;
  }
  .mode-card label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

  .grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }

  .region-chip {
    background: #f3f4f6;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 14px;
    cursor: pointer;
  }
  .region-chip:hover { background: #e2e8f0; }
  .region-chip.disabled { opacity: 0.6; cursor: not-allowed; }

  .separator { border-top: 1px solid var(--border); margin: 12px 0; }

  .debug { font-size: 12px; color: #64748b; margin-bottom: 8px; display: none; }

  /* New class for plan reminder sentence */
  .az-plan-reminder {
    font-size: 13px; /* Smaller than default body font */
    color: #22c55e; /* Light green */
    margin-bottom: 1rem;
  }
  .az-plan-reminder a {
    color: inherit; /* Inherit light green */
  }
  .az-plan-reminder a:hover {
    color: #16a34a; /* Darker green for hover */
  }

  /* 08-media.php dropzone differentiation */
  .drop-zone-media {
    border: 2px dashed #22c55e;
    position: relative;
  }
  .drop-zone-media::before {
    content: '📷';
    font-size: 24px;
    position: absolute;
    top: 10px;
    left: 10px;
    color: #64748b;
  }
  .drop-zone-media.dragover {
    background: #f1f5f9; /* slate-100 */
    border-color: var(--brand);
  }

  .drop-zone-logo {
    border: 2px dashed #3b82f6; /* blue-500 */
    position: relative;
  }
  .drop-zone-logo::before {
    content: '🏷️';
    font-size: 24px;
    position: absolute;
    top: 10px;
    left: 10px;
    color: #3b82f6;
  }
  .drop-zone-logo.dragover {
    background: #eff6ff; /* blue-50 */
    border-color: #2563eb; /* blue-600 */
  }

}

}

@layer components {
  /* 05-categories.php additions */
  .counter { font-size: 12px; color: #374151; }

  .searchbar {
    display: flex;
    gap: 0;
    align-items: center;
    max-width: 600px;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 12px;
  }
  .searchbar input[type=search] {
    flex: 1;
    padding: 12px 16px;
    border: none;
    font-size: 16px;
  }
  .searchbar input[type=search]:focus { outline: none; }
  .searchbar button {
    padding: 12px 16px;
    border: none;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font-size: 16px;
  }
  .searchbar button:hover { background: #4338ca; }
  .searchbar .icon { margin-right: 8px; }

  .grid-parents {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
  }

  .parent-card {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    cursor: pointer;
    text-align: left;
  }
  .parent-card:hover { border-color: #cbd5e1; }
  .parent-card .title { font-weight: 600; }

  .list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
  }
  .list .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .list .row.disabled { opacity: 0.6; }
  .list .nested { padding-left: 20px; margin-top: 5px; }

  .crumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
  .crumbs .sep { color: #64748b; }

  /* Keep .hidden to match your HTML; .az-hidden also exists */
  .hidden { display: none; }

  .small { font-size: 12px; color: #64748b; }

  .radio-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
  .radio-row label { display: flex; align-items: center; gap: 6px; }

  .drill-panel { position: relative; padding: 16px; border-top: 1px solid var(--border); }

  .expand-arrow { cursor: pointer; margin-right: 5px; font-size: 12px; }

  .name { cursor: pointer; flex: 1; }
}

@layer components {
  /* 03-basic.php additions */
  .az-main { max-width: var(--content-max); margin: 0 auto; padding: 20px; }
  .field { margin-bottom: 16px; }
  .help { font-size: 12px; color: #64748b; }
  .intro { margin-bottom: 24px; }
  .lead { font-size: 18px; margin-bottom: 12px; }
  .required { color: #dc2626; }
  .success { color: #16a34a; }
  .error { color: #dc2626; }
  .zipstatus { font-size: 13px; margin-top: 6px; }
  .zipstatus.err { color: #dc2626; }

  .radio-group { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; }
  .radio-group label { display: flex; align-items: center; gap: 6px; }

  .checkbox label { display: flex; align-items: center; gap: 8px; font-size: 14px; }

  .name { font-weight: 600; }

  h1 { font-size: 1.75rem; margin-bottom: 16px; }
  label { display: block; font-weight: 500; margin-bottom: 6px; }
  input[type="text"], input[type="email"], input[type="tel"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
  }

  .az-btn:hover { opacity: 0.9; }
  .az-btn.ghost:hover { background: #e5e7eb; }
}

@layer components {
  /* 07-description.php additions (ensure present) */
  .input-wrap button {
    padding: 12px 16px;
    border: none;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    border-radius: 10px;
    font-size: 16px;
  }
  .input-wrap button:hover { background: #4338ca; }
  .input-wrap button:disabled { background: #d1d5db; cursor: not-allowed; }

  .field-wrap textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    resize: vertical;
    min-height: 100px;
    font-family: inherit; /* Inherit --font-sans from body */
  }
  .field-wrap textarea:focus {
    outline: none;
    border-color: var(--brand);
  }

  .field-wrap.wide {
    max-width: none;
  }

  /* 08-media.php additions */
  .drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    border-radius: 12px;
    background: var(--card);
    text-align: center;
    transition: background 0.15s ease, border-color 0.15s ease;
    height: 300px;
  }
  .drop-zone p { color: var(--muted); font-size: 14px; margin: 0; }
  .drop-zone input[type="file"] { display: none; }
  .drop-zone .browse {
    display: inline-block;
    border: none;
    border-radius: 10px;
    padding: 6px 10px;
    background: #bfdbfe; /* Light blue */
    color: #111827;
    cursor: pointer;
    font-size: 14px;
  }
  .drop-zone .browse:hover {
    background: #93c5fd; /* Slightly darker blue for hover */
  }

  .media-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-top: 12px;
  }

  .media-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
  }
  .media-chip img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #f8fafc;
  }
  .media-chip img.error {
    object-fit: contain;
    background: #fee2e2;
    border-color: #fecaca;
  }
  .media-chip img.logo {
    object-fit: contain; /* Better for logos */
  }
  .media-chip .info { line-height: 1.2; min-width: 0; }
  .media-chip .info .name {
    font-weight: 600;
    word-break: break-word;
  }
  .media-chip .info .size {
    font-size: 12px;
    color: var(--muted);
  }
  .media-chip .delete-btn {
    margin-left: auto;
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    background: #f3f4f6;
    color: #111827;
    cursor: pointer;
    font-size: 14px;
  }
  .media-chip .delete-btn:hover { background: #e5e7eb; }
  .media-chip .delete-btn:focus { outline: 2px solid var(--focus, #93c5fd); outline-offset: 2px; }

  .image-count { font-size: 12px; color: var(--muted); }

  .processing { display: none; font-size: 13px; color: var(--muted); }
  .processing.show { display: block; }
}

@layer components {
  .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #e2e8f0; /* --border from azdat.tokens.css */
    border-top: 3px solid #4f46e5; /* --brand from azdat.tokens.css */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
  }

  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  .processing.show {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #4f46e5; /* --brand */
    margin: 12px 0;
  }

  body.uploading {
    cursor: progress;
  }
}

@media (max-width: 720px) {
  @layer components {
    .media-list { grid-template-columns: 1fr; }
    .media-chip { align-items: flex-start; }
  }
}

@layer components {
  /* 09-faqs.php additions */
  .faq-row {
    margin-bottom: 16px;
  }

  .faq-actions {
    display: flex;
    justify-content: flex-end;
  }

  .no-faqs {
    color: var(--muted);
    font-style: italic;
  }
}

@layer components {
  .az-container .preview-label {
    color: #4F53FF; /* slate-600, matches form labels */
    font-weight: 600; /* Slightly bolder for distinction */
  }
}