/*
 * ZgCodes Theme
 * Custom theme overrides for Sneat Bootstrap 5 admin template.
 * Primary: #46b97c (green) — the default panel color. Admins can change the
 * primary color in System → Panel Style; layouts/wrapper.blade.php injects it.
 * ---------------------------------------------------------------------------
 */

/* ===== Light Mode (default) ===== */
:root,
[data-bs-theme="light"] {
  /* Primary palette - ZgCodes green */
  --bs-primary: #46b97c;
  --bs-primary-rgb: 70, 185, 124;
  --bs-primary-bg-subtle: #e3f5eb;
  --bs-primary-border-subtle: #b5e3ca;
  --bs-primary-text-emphasis: #2b7a50;

  /* Secondary - neutral gray */
  --bs-secondary: #8592A3;
  --bs-secondary-rgb: 133, 146, 163;

  /* Success */
  --bs-success: #28a745;
  --bs-success-rgb: 40, 167, 69;
  --bs-success-bg-subtle: #e2f5e7;
  --bs-success-border-subtle: #b8e5c4;
  --bs-success-text-emphasis: #1a7430;

  /* Info */
  --bs-info: #17a2b8;
  --bs-info-rgb: 23, 162, 184;
  --bs-info-bg-subtle: #e0f4f7;
  --bs-info-border-subtle: #b3e4ec;
  --bs-info-text-emphasis: #0f6e7d;

  /* Warning */
  --bs-warning: #ffc107;
  --bs-warning-rgb: 255, 193, 7;
  --bs-warning-bg-subtle: #fff8e1;
  --bs-warning-border-subtle: #ffecb3;
  --bs-warning-text-emphasis: #997404;

  /* Danger */
  --bs-danger: #dc3545;
  --bs-danger-rgb: 220, 53, 69;
  --bs-danger-bg-subtle: #fce4e6;
  --bs-danger-border-subtle: #f5b7be;
  --bs-danger-text-emphasis: #962430;

  /* Body & text */
  --bs-body-color: #646e78;
  --bs-body-bg: #f5f5f9;
  --bs-heading-color: #384551;
  --bs-secondary-color: #8592A3;
  --bs-border-color: #dbdfe5;

  /* Card / paper background */
  --bs-paper-bg: #ffffff;

  /* Link colors */
  --bs-link-color: #46b97c;
  --bs-link-hover-color: #2b7a50;
}

/* ===== Dark Mode ===== */
[data-bs-theme="dark"] {
  /* Primary - lighter green for dark backgrounds */
  --bs-primary: #5fd197;
  --bs-primary-rgb: 95, 209, 151;
  --bs-primary-bg-subtle: #1a3a2a;
  --bs-primary-border-subtle: #2a6b4a;
  --bs-primary-text-emphasis: #8fe0b6;

  /* Secondary */
  --bs-secondary: #8592A3;
  --bs-secondary-rgb: 133, 146, 163;

  /* Success */
  --bs-success: #48c76e;
  --bs-success-rgb: 72, 199, 110;
  --bs-success-bg-subtle: #1a3a22;
  --bs-success-border-subtle: #2a6b3a;

  /* Info */
  --bs-info: #3bbdd0;
  --bs-info-rgb: 59, 189, 208;
  --bs-info-bg-subtle: #1a3040;
  --bs-info-border-subtle: #2a5a6b;

  /* Warning */
  --bs-warning: #ffd148;
  --bs-warning-rgb: 255, 209, 72;
  --bs-warning-bg-subtle: #3a3420;
  --bs-warning-border-subtle: #6b5a2a;

  /* Danger */
  --bs-danger: #e5606e;
  --bs-danger-rgb: 229, 96, 110;
  --bs-danger-bg-subtle: #3a1a20;
  --bs-danger-border-subtle: #6b2a34;

  /* Body & surfaces */
  --bs-body-color: #C5CAD3;
  --bs-body-bg: #1A1D2E;
  --bs-heading-color: #DFE2E7;
  --bs-secondary-color: #8592A3;
  --bs-border-color: #3b3f54;

  /* Card / paper background */
  --bs-paper-bg: #232640;

  /* Link colors */
  --bs-link-color: #5fd197;
  --bs-link-hover-color: #8fe0b6;

  color-scheme: dark;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Typography Refinements ===== */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Selection Color ===== */
::selection {
  background: var(--bs-primary);
  color: #ffffff;
}

/* ===== Layout Fixes ===== */

/* Sidebar branding */
.menu .app-brand {
  height: 64px;
  margin-top: 12px;
}

/* Sidebar always expanded - never collapse to icon-only */
@media (min-width: 1200px) {
  .layout-menu {
    width: 16.25rem !important;
    transform: translate3d(0, 0, 0) !important;
  }
  .layout-menu .menu-inner > .menu-item > .menu-link .menu-text,
  .layout-menu .menu-inner > .menu-item .menu-sub,
  .layout-menu .menu-inner > .menu-item .menu-toggle::after,
  .layout-menu .menu-header {
    opacity: 1 !important;
    overflow: visible !important;
  }
}

/* Brand logo */
.app-brand-logo {
  flex-shrink: 0;
}
.app-brand-logo img {
  height: 2.5rem;
  width: auto;
  max-width: 12rem;
  display: block;
}

/* Navbar z-index fix */
.content-wrapper .navbar {
  z-index: auto;
}

/* Notification dropdown list */
.dropdown-notifications-list {
  max-height: 22rem;
  overflow-y: auto;
}
.dropdown-notifications-item .avatar img {
  object-fit: cover;
}

/* ===== Cookie Banner (public Sneat pages) ===== */
.cookie-banner {
  max-width: 46rem;
  background: rgba(var(--bs-paper-bg-rgb, 255, 255, 255), 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--bs-box-shadow);
}

/* ===== Skip Navigation Link ===== */
.skip-link {
  position: absolute;
  top: -100%;
  inset-inline-start: 0;
  z-index: 9999;
  padding: 0.75rem 1.5rem;
  background: var(--bs-primary);
  color: #ffffff;
  text-decoration: none;
  border-end-end-radius: 0.375rem;
}
.skip-link:focus {
  top: 0;
  color: #ffffff;
}

/* ===== Public landing (homepage) ===== */
/* Opaque frosted navbar pill so it stays readable over the blue hero */
html nav.layout-navbar .navbar.landing-navbar {
  --bs-front-navbar-bg: rgba(var(--bs-paper-bg-rgb), 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--bs-box-shadow-sm);
}
.zg-hero {
  background-color: var(--zg-brand, var(--bs-primary));
  background-size: cover;
  background-position: center;
  color: #ffffff;
  padding-block: 11.28rem 7rem;
}
@media (max-width: 1199.98px) {
  .zg-hero {
    padding-block: 8rem 5rem;
  }
}
.zg-hero-title {
  color: #ffffff;
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.15;
}
.zg-hero-text {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.125rem;
}
.zg-hero-search {
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.18);
  border-radius: 0.5rem;
}
.zg-hero-search .input-group-text,
.zg-hero-search .form-control {
  background-color: var(--bs-paper-bg);
  border-color: transparent;
}

/* ===== Auth pages ===== */
.auth-toolbar {
  position: fixed;
  top: 1rem;
  inset-inline-end: 1rem;
  z-index: 10;
}
.authentication-wrapper .app-brand-logo img {
  height: 2.75rem;
}

/* ===== Knowledge base article content ===== */
.kb-article-body img {
  max-width: 100%;
  height: auto;
}
.kb-article-body > :last-child {
  margin-bottom: 0;
}

/* ===== Mobile Touch Targets ===== */
@media (max-width: 767.98px) {
  .card .btn,
  .card-body .btn,
  .table .btn {
    min-height: 44px;
  }

  .table td a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .form-control,
  .form-select {
    min-height: 44px;
  }
}

/* ===== Image picker preview (settings, avatars, category icons) ===== */
.image-picker-preview {
  max-height: 8rem;
  max-width: 100%;
  object-fit: contain;
}

/* ===== Sortable lists (jQuery UI sortable / nestable menus) ===== */
.sortable-handle {
  cursor: move;
}
.sortable-placeholder {
  height: 3.25rem;
  border: 1px dashed var(--bs-primary);
  border-radius: 0.375rem;
  background: var(--bs-primary-bg-subtle);
}
.dd-list {
  list-style: none;
  padding-inline-start: 0;
  margin: 0;
}
.dd-list .dd-list {
  padding-inline-start: 2rem;
}
.dd-placeholder {
  min-height: 3.25rem;
  margin-bottom: 0.5rem;
  border: 1px dashed var(--bs-primary);
  border-radius: 0.375rem;
  background: var(--bs-primary-bg-subtle);
}
.dd-dragel {
  position: absolute;
  pointer-events: none;
  z-index: 9999;
  list-style: none;
  padding: 0;
}

/* Nestable plugin overrides (its stylesheet loads after the theme) */
.nestable .dd-list .dd-list {
  padding-left: 0;
  padding-inline-start: 2rem;
}
.nestable .dd-placeholder {
  margin-bottom: 0.5rem;
  border: 1px dashed var(--bs-primary);
  border-radius: 0.375rem;
  background: var(--bs-primary-bg-subtle);
}
.nestable .dd-item > button {
  left: auto;
  inset-inline-start: 2.3rem;
}
[data-bs-theme="dark"] .nestable .dd-item > button {
  filter: invert(1);
}

/* ===== CodeMirror inside cards ===== */
.card .CodeMirror {
  border-end-start-radius: 0.375rem;
  border-end-end-radius: 0.375rem;
}

/* ==========================================================================
   Support ticket conversation (app-chat style bubbles)
   Uses logical properties so it flips automatically under dir="rtl".
   ========================================================================== */
.ticket-chat {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ticket-msg {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  max-width: 85%;
}

.ticket-msg--own {
  flex-direction: row-reverse;
  margin-inline-start: auto;
}

.ticket-msg-avatar img {
  width: 2.25rem;
  height: 2.25rem;
  object-fit: cover;
}

.ticket-msg-body {
  min-width: 0;
}

.ticket-msg-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.ticket-msg--own .ticket-msg-meta {
  flex-direction: row-reverse;
}

.ticket-msg-bubble {
  background-color: var(--bs-secondary-bg, #f5f5f9);
  color: var(--bs-body-color);
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  word-break: break-word;
}

.ticket-msg-bubble > :last-child {
  margin-bottom: 0;
}

.ticket-msg--own .ticket-msg-bubble {
  background-color: var(--bs-primary);
  color: #fff;
}

.ticket-msg--own .ticket-msg-bubble a {
  color: #fff;
  text-decoration: underline;
}

.ticket-msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ticket-attachment-chip {
  display: inline-flex;
  align-items: center;
  max-width: 14rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  text-decoration: none;
  color: var(--bs-body-color);
}

.ticket-attachment-chip:hover {
  border-color: var(--bs-primary);
}

/* ===== Auto-growing textareas (translation editor) ===== */
.textarea-autosize {
  overflow: hidden;
}

/* ===== Coloris color picker =====
   Coloris wraps the input in an inline-block .clr-field, which pulled the field up next to
   its label. Make it a full-width block and round the swatch like an input-group end. */
div.clr-field {
  display: block;
}
div.clr-field button {
  width: 2.5rem;
  border-start-end-radius: var(--bs-border-radius);
  border-end-end-radius: var(--bs-border-radius);
}

/* ===== CKEditor 5 ===== */
.ck.ck-editor__editable_inline {
  min-height: 12rem;
}
.ckeditor-lg .ck.ck-editor__editable_inline {
  min-height: 24rem;
}
:root[data-bs-theme] {
  --ck-color-focus-border: var(--bs-primary);
  --ck-color-link-default: var(--bs-link-color);
}
/* Dark mode: CKEditor ships a light-only palette; map it onto the panel surfaces */
:root[data-bs-theme="dark"] {
  --ck-color-base-background: var(--bs-paper-bg);
  --ck-color-base-foreground: #2b2f4c;
  --ck-color-base-border: var(--bs-border-color);
  --ck-color-base-text: var(--bs-body-color);
  --ck-color-text: var(--bs-body-color);
  --ck-color-toolbar-background: var(--bs-paper-bg);
  --ck-color-toolbar-border: var(--bs-border-color);
  --ck-color-panel-background: var(--bs-paper-bg);
  --ck-color-panel-border: var(--bs-border-color);
  --ck-color-dropdown-panel-background: var(--bs-paper-bg);
  --ck-color-dropdown-panel-border: var(--bs-border-color);
  --ck-color-input-background: var(--bs-paper-bg);
  --ck-color-input-border: var(--bs-border-color);
  --ck-color-input-text: var(--bs-body-color);
  --ck-color-labeled-field-label-background: var(--bs-paper-bg);
  --ck-color-list-background: var(--bs-paper-bg);
  --ck-color-button-default-hover-background: rgba(255, 255, 255, 0.08);
  --ck-color-button-default-active-background: rgba(255, 255, 255, 0.12);
  --ck-color-button-on-background: rgba(var(--bs-primary-rgb), 0.16);
  --ck-color-button-on-hover-background: rgba(var(--bs-primary-rgb), 0.24);
  --ck-color-button-on-active-background: rgba(var(--bs-primary-rgb), 0.24);
  --ck-color-button-on-color: var(--bs-primary);
  --ck-color-list-button-hover-background: rgba(255, 255, 255, 0.08);
  --ck-color-list-button-on-background: var(--bs-primary);
  --ck-color-list-button-on-background-focus: var(--bs-primary);
  --ck-color-list-button-on-text: #ffffff;
  --ck-color-split-button-hover-background: rgba(255, 255, 255, 0.08);
  --ck-color-split-button-hover-border: var(--bs-border-color);
  --ck-color-engine-placeholder-text: var(--bs-secondary-color);
  --ck-color-shadow-drop: rgba(0, 0, 0, 0.4);
  --ck-color-shadow-inner: rgba(0, 0, 0, 0.3);
}
