/*
 * Krona Mag - Menu Stylesheet
 * Version: 0.1.0
 * Description: Stili header, navigazione, hamburger panel.
 * Struttura:
 *   1. Header layout
 *   2. Hamburger button
 *   3. Logo
 *   4. Newsletter button
 *   5. Primary nav
 *   6. Menu items
 *   7. Dropdown
 *   8. Sidebar panel
 *   9. Panel pages menu
 *  10. Responsive
 *
 * V2: colors, subtitles, icons configurable via Customizer.
 */

/* =============================================
   1. HEADER LAYOUT
   Row 1: hamburger | logo | newsletter
   Row 2: navigation menu
   ============================================= */

.km-header-inner {
  display: block !important;
}

.km-header-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 24px 24px;
  max-width: 1280px;
  margin: 0 auto;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.km-header-nav {
  width: 100%;
}

/* =============================================
   2. HAMBURGER BUTTON
   Left side - opens sidebar panel
   ============================================= */

.km-hamburger {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 0;
  z-index: 10;
  flex-shrink: 0;
}

.km-hamburger-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 16px;
}

.km-hamburger-lines span {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: 0.3s;
}

/* =============================================
   3. LOGO
   Centered in row 1
   ============================================= */

.km-logo {
  justify-self: center;
}

.km-logo a {
  display: flex;
  align-items: center;
}

.km-logo-text {
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.km-header-top .km-logo .custom-logo {
  height: 80px !important;
  width: auto !important;
  max-width: none !important;
  padding: 0;
}

/* =============================================
   4. NEWSLETTER BUTTON
   Right side of row 1
   ============================================= */

.km-newsletter-btn {
  display: inline-block;
  background: var(--km-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--km-radius);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  margin-left: auto;
  border: none;
}

.km-newsletter-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* =============================================
   5. PRIMARY NAV
   Row 2 - centered menu
   ============================================= */

.km-header-nav .km-nav {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  justify-self: unset;
}

.km-nav .km-menu {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important;
  justify-content: center;
  gap: 0 !important;
  list-style: none;
  height: 64px;
  padding: 0;
  margin: 0;
}

/* =============================================
   6. MENU ITEMS
   Each item: icon + title + subtitle italic
   Colored bottom line on hover
   ============================================= */

.km-menu-item {
  position: relative;
  display: flex;
  align-items: stretch;
  list-style: none;
}

.km-menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: border-color 0.2s, background 0.2s;
  white-space: nowrap;
}

.km-menu-link:hover,
.km-menu-item:hover > .km-menu-link {
  border-bottom-color: var(--km-item-color);
  background: rgba(255,255,255,0.05);
}

.km-menu-link:hover .km-menu-sub,
.km-menu-item:hover > .km-menu-link .km-menu-sub {
  color: var(--km-item-color);
}

.km-menu-link:hover .km-menu-title,
.km-menu-item:hover > .km-menu-link .km-menu-title {
  color: var(--km-item-color);
}

.km-menu-link:hover .km-menu-icon,
.km-menu-item:hover > .km-menu-link .km-menu-icon {
  color: var(--km-item-color);
}

.km-menu-icon {
  font-size: 15px;
  color: var(--km-item-color);
  flex-shrink: 0;
}

.km-menu-texts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.km-menu-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  transition: color 0.2s;
}

.km-menu-sub {
  font-size: 12px;
  font-weight: 400;
  font-style: italic;
  color: rgba(255,255,255,0.5);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.2;
  transition: color 0.2s;
}

.km-menu-arrow {
  font-size: 9px;
  color: rgba(255,255,255,0.6);
  margin-left: 4px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.km-has-dropdown:hover .km-menu-arrow {
  transform: rotate( 180deg );
}

/* =============================================
   7. DROPDOWN
   Simple list below menu item
   ============================================= */

.km-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #fff;
  border-radius: 0 0 var(--km-radius-lg) var(--km-radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  list-style: none;
  z-index: 999;
  padding: 8px;
  margin: 0;
}

.km-has-dropdown:hover .km-dropdown {
  display: block;
}

.km-dropdown li {
  list-style: none;
}

.km-dropdown-link {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s;
  color: #1e293b !important;
}

.km-dropdown-link:hover {
  background: #f1f5f9 !important;
}

.km-dropdown-icon {
  font-size: 12px;
  color: rgba(0,0,0,0.3);
  margin-top: 2px;
  flex-shrink: 0;
}

.km-dropdown-texts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.km-dropdown-title {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b !important;
  line-height: 1.3;
}

.km-dropdown-sub {
  font-size: 11px;
  font-weight: 400;
  font-style: italic;
  color: rgba(0,0,0,0.45);
  line-height: 1.2;
}

/* =============================================
   8. SIDEBAR PANEL
   Left side panel: search + pages menu
   Opens via hamburger button
   ============================================= */

.km-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
}

.km-panel-overlay.km-panel-open {
  display: block;
}

.km-sidebar-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 360px;
  height: 100vh;
  background: var(--km-header-bg);
  z-index: 1001;
  transform: translateX( -100% );
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.km-sidebar-panel.km-panel-open {
  transform: translateX( 0 );
}

.km-sidebar-panel-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s;
  line-height: 1;
}

.km-sidebar-panel-close:hover {
  color: #fff;
}

.km-sidebar-panel-logo .custom-logo {
  height: 52px;
  width: auto;
}

.km-sidebar-panel-site-name {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.km-panel-search-form {
  display: flex;
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: var(--km-radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.km-panel-search-form:focus-within {
  border-color: var(--km-accent);
}

.km-panel-search-input {
  flex: 1;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  outline: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.km-panel-search-input::placeholder {
  color: rgba(255,255,255,0.4);
}

.km-panel-search-btn {
  background: #f97316;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  transition: background 0.2s;
}

.km-panel-search-btn:hover {
  background: #ea6c0a;
}

.km-sidebar-panel-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.4);
  margin-bottom: 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Only nav row is sticky */
.km-header-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--km-header-bg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: none;
  transition: box-shadow 0.3s ease;
}

.km-header-nav.km-nav-sticky {
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}

/* Sticky logo - appears when nav becomes sticky */
.km-sticky-logo {
  display: none;
  align-items: center;
}

.km-header-nav.km-nav-sticky .km-sticky-logo {
  display: flex;
}

.km-sticky-logo .custom-logo {
  height: 36px !important;
  width: auto !important;
  max-width: none !important;
  filter: grayscale( 100% ) brightness( 2 );
  opacity: 0.85;
}

/* Nav inner - flex row with logo + menu */
.km-header-nav .km-container {
  display: flex;
  align-items: center;
  gap: 24px;
}

.admin-bar .km-header {
  top: 32px;
}

/* =============================================
   9. PANEL PAGES MENU
   Modern pages list inside hamburger panel
   V2: configurable via Customizer
   ============================================= */

.km-sidebar-panel-pages {
  display: flex;
  flex-direction: column;
}

.km-panel-pages-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0px;
}

/* Each page link - icon + label */
.km-panel-pages-list li a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 16px !important;
  border-radius: var(--km-radius);
  color: rgba(255,255,255,0.85);
  font-size: 15px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  text-decoration: none;
  transition: background 0.2s, padding-left 0.2s, color 0.2s;
  border-left: 3px solid transparent;
}

.km-panel-pages-list li a:hover {
  background: rgba(255,255,255,0.08);
  border-left-color: var(--km-accent);
  padding-left: 22px;
  color: #fff;
}

/* Icon in each page link */
.km-panel-pages-list li a i {
  display: inline-block !important;
  font-size: 15px;
  color: var(--km-accent);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  transition: color 0.2s;
}

.km-panel-pages-list li a:hover i {
  color: #fff;
}

/* =============================================
   PANEL CATEGORIES LIST
   Modern category links inside hamburger panel
   ============================================= */

.km-panel-cat-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.km-panel-cat-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px !important;
  border-radius: var(--km-radius);
  color: #7dd3fc;
  line-height: 1;
  font-size: 15px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  text-decoration: none;
  transition: background 0.2s, padding-left 0.2s, color 0.2s;
  border-left: 3px solid transparent;
}

.km-panel-cat-list li a:hover {
  background: rgba(255,255,255,0.08);
  border-left-color: #7dd3fc;
  padding-left: 22px;
  color: #fff;
}

/* Hide post count */
.km-panel-cat-count {
  display: none;
}

.km-panel-icon {
  color: #ffd600;
  margin-right: 8px;
  font-size: 14px;
  flex-shrink: 0;
}

.km-panel-s1 li a::before {
  content: '▷';
  color: #ffd600;
  margin-right: 8px;
  font-size: 14px;
}

.km-panel-s2 li a::before {
  content: '◈';
  color: var(--km-accent);
  margin-right: 8px;
  font-size: 14px;
}

/* =============================================
   10. RESPONSIVE
   Mobile: hide nav, keep hamburger + logo
   ============================================= */

@media ( max-width: 1024px ) {
  .km-menu-sub {
    display: none;
  }
  .km-menu-link {
    padding: 0 10px;
  }
}

@media ( max-width: 768px ) {

  /* Header top - hamburger left, logo right */
.km-header-top {
  grid-template-columns: auto 1fr auto !important;
  padding: 14px 16px !important;
  gap: 12px;
}

.km-header-top .km-logo {
  justify-self: center;
  grid-column: 2;
}

  /* Hide newsletter on mobile */
  .km-newsletter-btn {
    display: none;
  }

  /* Hide main nav on mobile */
  .km-nav {
    display: none;
  }

  /* Hide sticky nav bar on mobile */
  .km-header-nav {
    display: none;
  }

  /* Logo centered */
  .km-logo {
    justify-self: center;
  }

  /* Logo smaller on mobile */
  .km-header-top .km-logo .custom-logo {
    height: 56px !important;
  }

  /* Panel full width on mobile */
  .km-sidebar-panel {
    width: 100%;
  }

  /* Hamburger lines - bigger and more visible on mobile */
  .km-hamburger-lines {
    width: 24px;
    gap: 6px;
  }

  .km-hamburger-lines span {
    width: 24px;
    height: 2.5px;
  }
}

@media screen and ( max-width: 782px ) {
  .admin-bar .km-sidebar-panel {
    top: 46px;
    height: calc( 100vh - 46px );
  }
  .admin-bar .km-header {
    top: 46px;
  }
}