/* src/web/public/css/style.css */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #2f3136; }
::-webkit-scrollbar-thumb { background: #202225; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #36393f; }

.sidebar { width: 240px; min-height: calc(100vh - 52px); }
.sidebar a { display: block; padding: 8px 16px; color: #b9bbbe; border-radius: 4px; margin: 2px 8px; }
.sidebar a:hover { background: #36393f; color: #fff; }
.sidebar a.active { background: #5865f2; color: #fff; }

.embed-preview { max-width: 520px; border-left: 4px solid #5865f2; background: #2f3136; padding: 12px 16px; border-radius: 4px; }

/* ===== Toggle Switch (green/red style like tickettool) ===== */
.toggle-switch { position: relative; width: 44px; height: 24px; display: inline-block; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-switch .slider { position: absolute; inset: 0; background: #72767d; border-radius: 12px; cursor: pointer; transition: background .2s; }
.toggle-switch .slider:before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle-switch input:checked + .slider { background: #3ba55d; }
.toggle-switch input:checked + .slider:before { transform: translateX(20px); }
.toggle-switch-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.toggle-switch-label { color: #dcddde; font-size: 14px; cursor: pointer; user-select: none; }

/* Legacy toggle (keep for backward compat) */
.toggle { position: relative; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; inset: 0; background: #72767d; border-radius: 12px; cursor: pointer; transition: .2s; }
.toggle .slider:before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + .slider { background: #5865f2; }
.toggle input:checked + .slider:before { transform: translateX(20px); }

/* ===== Form inputs ===== */
input[type="text"], input[type="number"], textarea, select {
  background: #202225; border: 1px solid #36393f; color: #dcddde; padding: 8px 12px; border-radius: 4px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #5865f2; }

.color-btn { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-btn.active { border-color: #fff; }

.tab-btn { padding: 8px 16px; color: #b9bbbe; border-bottom: 2px solid transparent; cursor: pointer; }
.tab-btn:hover { color: #fff; }
.tab-btn.active { color: #fff; border-color: #5865f2; }

/* ===== Config Card Grid ===== */
.config-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 900px) { .config-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .config-grid { grid-template-columns: 1fr; } }

.config-card {
  background: #2f3136; border: 1px solid #40444b; border-radius: 8px; padding: 16px;
  cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s;
  display: flex; align-items: flex-start; gap: 12px;
}
.config-card:hover { border-color: #5865f2; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(88,101,242,.15); }
.config-card .card-icon { font-size: 24px; flex-shrink: 0; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #36393f; border-radius: 8px; }
.config-card .card-body { flex: 1; min-width: 0; }
.config-card .card-title { color: #fff; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.config-card .card-desc { color: #72767d; font-size: 12px; line-height: 1.4; }

/* ===== Section Headers ===== */
.section-header { color: #72767d; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; padding-bottom: 4px; }

/* ===== Sub-Page ===== */
.sub-page { display: none; }
.sub-page.active { display: block; }
.sub-page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.sub-page-back { color: #b9bbbe; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 4px; background: #2f3136; border: none; transition: background .15s, color .15s; }
.sub-page-back:hover { background: #36393f; color: #fff; }
.sub-page-title { color: #fff; font-size: 20px; font-weight: 700; }

/* ===== Tag Select (chip multi-select) ===== */
.tag-select { position: relative; }
.tag-select-display { background: #202225; border: 1px solid #36393f; border-radius: 4px; padding: 6px 8px; min-height: 38px; display: flex; flex-wrap: wrap; gap: 4px; cursor: text; transition: border-color .15s; }
.tag-select-display:focus-within { border-color: #5865f2; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; background: #5865f2; color: #fff; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag-chip.role-chip { background: #36393f; }
.tag-chip .tag-remove { cursor: pointer; opacity: .7; font-size: 14px; line-height: 1; margin-left: 2px; }
.tag-chip .tag-remove:hover { opacity: 1; }
.tag-select-input { border: none; background: transparent; color: #dcddde; font-size: 13px; outline: none; min-width: 80px; flex: 1; padding: 2px 4px; }
.tag-select-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #2f3136; border: 1px solid #40444b; border-radius: 4px; margin-top: 4px; max-height: 200px; overflow-y: auto; z-index: 20; display: none; }
.tag-select-dropdown.open { display: block; }
.tag-select-option { padding: 8px 12px; color: #dcddde; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.tag-select-option:hover { background: #36393f; }
.tag-select-option .option-color { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.tag-select-empty { padding: 8px 12px; color: #72767d; font-size: 13px; }

/* ===== Stepper (+/- buttons) ===== */
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid #36393f; border-radius: 4px; overflow: hidden; background: #202225; }
.stepper button { width: 32px; height: 36px; background: #2f3136; border: none; color: #dcddde; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.stepper button:hover { background: #36393f; color: #fff; }
.stepper input { width: 48px; text-align: center; border: none; border-left: 1px solid #36393f; border-right: 1px solid #36393f; background: #202225; color: #dcddde; font-size: 14px; padding: 6px 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ===== Green Edit Button ===== */
.green-edit-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #3ba55d; color: #fff; border: none; border-radius: 4px;
  padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s;
}
.green-edit-btn:hover { background: #2d8b4e; }
.green-edit-btn svg { width: 14px; height: 14px; }

/* ===== Message Editor Modal ===== */
.msg-editor-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.msg-editor-overlay.open { opacity: 1; pointer-events: auto; }
.msg-editor-modal {
  background: #36393f; border-radius: 8px; width: 90vw; max-width: 1100px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.msg-editor-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #40444b;
}
.msg-editor-header h3 { color: #fff; font-size: 16px; font-weight: 600; margin: 0; }
.msg-editor-close { background: none; border: none; color: #72767d; font-size: 20px; cursor: pointer; padding: 4px; }
.msg-editor-close:hover { color: #fff; }
.msg-editor-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.msg-editor-fields { flex: 1; padding: 20px; overflow-y: auto; }
.msg-editor-preview { flex: 1; padding: 20px; overflow-y: auto; background: #2f3136; border-left: 1px solid #40444b; }
.msg-editor-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #40444b; }
@media (max-width: 800px) { .msg-editor-body { flex-direction: column; } .msg-editor-preview { border-left: none; border-top: 1px solid #40444b; } }

/* ===== Config Section Box ===== */
.config-section { background: #2f3136; border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.config-section-title { color: #fff; font-size: 14px; font-weight: 600; margin-bottom: 12px; }

/* ===== Frequently Used Configs ===== */
.freq-config { background: #2f3136; border-radius: 8px; padding: 16px 20px; margin-top: 20px; }
.freq-config-title { color: #72767d; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.freq-config-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }

/* ===== Action Buttons Bar ===== */
.action-btn { padding: 6px 14px; border-radius: 4px; font-size: 13px; font-weight: 500; border: none; cursor: pointer; transition: background .15s; color: #fff; }
.action-btn.primary { background: #5865f2; }
.action-btn.primary:hover { background: #4752c4; }
.action-btn.success { background: #3ba55d; }
.action-btn.success:hover { background: #2d8b4e; }
.action-btn.secondary { background: #4f545c; }
.action-btn.secondary:hover { background: #5d6269; }
.action-btn.danger { background: #ed4245; }
.action-btn.danger:hover { background: #d63031; }
.action-btn.warning { background: #faa61a; }
.action-btn.warning:hover { background: #e09315; }

/* ===== Form Field Helpers ===== */
.field-group { margin-bottom: 16px; }
.field-label { display: block; color: #b9bbbe; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.field-hint { color: #72767d; font-size: 12px; margin-top: 4px; }

/* ===== Permission Grid ===== */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.perm-card { background: #202225; border-radius: 6px; padding: 12px; }
.perm-card-title { color: #fff; font-size: 13px; font-weight: 600; margin-bottom: 8px; }

/* ===== Message Button Grid ===== */
.msg-btn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 700px) { .msg-btn-grid { grid-template-columns: repeat(2, 1fr); } }

/* ===== Logging Event Grid ===== */
.log-event-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ===== Dropdown Item Editor ===== */
.dropdown-item { background: #202225; border-radius: 6px; padding: 12px; margin-bottom: 8px; }
.dropdown-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

/* ===== Automation Item ===== */
.automation-item { background: #202225; border-radius: 6px; padding: 12px; margin-bottom: 8px; }

/* ===== Form Question Item ===== */
.form-question-item { background: #202225; border-radius: 6px; padding: 12px; margin-bottom: 8px; }

/* ===== Discord Message Preview (for embed-preview.js) ===== */
.discord-message {
  background: #36393f; padding: 16px 48px 16px 72px; position: relative;
  border-radius: 4px; font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.discord-message .bot-avatar {
  position: absolute; left: 16px; top: 16px; width: 40px; height: 40px; border-radius: 50%;
  background: #5865f2; display: flex; align-items: center; justify-content: center; color: white; font-size: 20px;
}
.discord-message .msg-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.discord-message .bot-name { color: white; font-weight: 600; font-size: 15px; }
.discord-message .bot-badge { background: #5865f2; color: white; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; text-transform: uppercase; }
.discord-message .msg-timestamp { color: #72767d; font-size: 12px; }
.discord-embed { margin-top: 4px; max-width: 520px; border-radius: 4px; background: #2f3136; display: flex; overflow: hidden; }
.discord-embed .embed-color-bar { width: 4px; flex-shrink: 0; }
.discord-embed .embed-content { padding: 8px 16px 16px 12px; flex: 1; min-width: 0; }
.discord-embed .embed-author { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.discord-embed .embed-author img { width: 24px; height: 24px; border-radius: 50%; }
.discord-embed .embed-author-name { font-size: 13px; font-weight: 600; color: white; }
.discord-embed .embed-title { font-size: 15px; font-weight: 700; color: white; margin-bottom: 4px; }
.discord-embed .embed-title a { color: #00aff4; text-decoration: none; }
.discord-embed .embed-title a:hover { text-decoration: underline; }
.discord-embed .embed-description { font-size: 14px; color: #dcddde; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.discord-embed .embed-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.discord-embed .embed-field.inline { grid-column: span 1; }
.discord-embed .embed-field:not(.inline) { grid-column: span 3; }
.discord-embed .embed-field-name { font-size: 13px; font-weight: 700; color: white; margin-bottom: 2px; }
.discord-embed .embed-field-value { font-size: 13px; color: #dcddde; }
.discord-embed .embed-thumbnail { width: 80px; height: 80px; border-radius: 4px; object-fit: cover; margin: 8px 16px 0 0; flex-shrink: 0; }
.discord-embed .embed-image { max-width: 400px; max-height: 300px; border-radius: 4px; margin-top: 12px; }
.discord-embed .embed-footer { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.discord-embed .embed-footer img { width: 20px; height: 20px; border-radius: 50%; }
.discord-embed .embed-footer-text { font-size: 12px; color: #72767d; }

/* Variables Reference */
.variables-ref { margin-top: 12px; border: 1px solid #40444b; border-radius: 4px; overflow: hidden; }
.variables-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 12px; background: #2f3136; color: #b9bbbe; font-size: 13px; font-weight: 600; border: none; cursor: pointer; transition: background 0.15s; }
.variables-toggle:hover { background: #36393f; }
.variables-chevron { transition: transform 0.2s; }
.variables-ref.open .variables-chevron { transform: rotate(180deg); }
.variables-body { display: none; padding: 8px 12px 12px; background: #2f3136; column-count: 2; column-gap: 24px; }
.variables-ref.open .variables-body { display: block; }
.variables-category { break-inside: avoid; margin-bottom: 10px; }
.variables-category-name { font-size: 11px; font-weight: 700; color: #72767d; text-transform: uppercase; margin-bottom: 4px; letter-spacing: 0.5px; }
.variables-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.variables-code { font-size: 12px; background: #202225; color: #e8912d; padding: 1px 5px; border-radius: 3px; font-family: 'Consolas', 'Monaco', monospace; white-space: nowrap; }
.variables-desc { font-size: 12px; color: #72767d; }
