/**
 * Layout Styles
 * Header, sidebar, main content area, and page structure.
 */

/* =========================================================================
 * HEADER
 * ========================================================================= */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--gradient-header);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(3, 46, 82, .2);
}

.header.visible {
  display: flex;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .95rem;
  font-weight: 700;
}

.header-logo-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, .15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .5rem;
}

.header-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, .2);
}

.header-project-select {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
  padding: 5px 30px 5px 10px;
  border-radius: var(--radius);
  font-size: .78rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url(data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E);
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.header-project-select option {
  color: var(--text);
  background: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-notification {
  position: relative;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, .10);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-notification svg {
  width: 15px;
  height: 15px;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: var(--mm-chartreuse);
  color: var(--mm-navy);
  border-radius: 50%;
  font-size: .55rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, .10);
  padding: 3px 10px 3px 3px;
  border-radius: 18px;
  cursor: pointer;
}

.header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mm-topas);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .6rem;
}

.header-user-name {
  font-size: .75rem;
  font-weight: 600;
}

.header-user-role {
  font-size: .62rem;
  opacity: .7;
}

/* =========================================================================
 * HEADER GLOBAL SEARCH
 * ========================================================================= */

.header-search-wrapper {
  position: relative;
}

.header-search-input-wrap {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
  padding: 0 8px;
  gap: 6px;
  transition: background .15s, border-color .15s;
}

.header-search-input-wrap:focus-within {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .4);
}

.header-search-icon {
  width: 14px;
  height: 14px;
  color: rgba(255, 255, 255, .6);
  flex-shrink: 0;
}

#globalSearchInput {
  background: none;
  border: none;
  color: #fff;
  font-size: .78rem;
  width: 200px;
  padding: 5px 0;
  outline: none;
  font-family: inherit;
}

#globalSearchInput::placeholder {
  color: rgba(255, 255, 255, .5);
}

.header-search-clear {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .6);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
  transition: color .15s;
}

.header-search-clear:hover {
  color: #fff;
}

.header-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 420px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
}

.search-result-section {
  padding: 8px 14px 4px;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  background: var(--mm-lichtgrau);
}

.search-result-item {
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  color: var(--text);
  text-decoration: none;
}

.search-result-item:hover {
  background: var(--mm-lichtgrau);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-id {
  font-weight: 700;
  color: var(--mm-topas);
  min-width: 50px;
  flex-shrink: 0;
}

.search-result-subject {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-meta {
  font-size: .65rem;
  color: var(--text-light);
  white-space: nowrap;
  flex-shrink: 0;
}

.search-result-loading,
.search-result-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-light);
  font-size: .78rem;
}

/* Search highlight: pulsing red border on matched ticket row */
@keyframes searchHighlightPulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, .6); }
  50% { box-shadow: 0 0 0 4px rgba(220, 53, 69, .3); }
  100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, .0); }
}

tr.search-highlight {
  outline: 2px solid #dc3545;
  outline-offset: -1px;
  background: rgba(220, 53, 69, .06) !important;
  animation: searchHighlightPulse 1.5s ease-in-out 3;
}

/* =========================================================================
 * APP LAYOUT
 * ========================================================================= */

.app-layout {
  display: none;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

.app-layout.visible {
  display: flex;
}

/* =========================================================================
 * SIDEBAR
 * ========================================================================= */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 16px;
}

.nav-section-title {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-light);
  padding: 0 10px;
  margin-bottom: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: var(--mm-lichtgrau);
  color: var(--text);
}

.nav-item.active {
  background: rgba(0, 136, 146, .08);
  color: var(--mm-topas);
  font-weight: 600;
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: .62rem;
  font-weight: 700;
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.nav-badge.info {
  background: var(--color-info-light);
  color: var(--color-info);
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: .65rem;
  color: var(--text-light);
}

/* =========================================================================
 * MAIN CONTENT
 * ========================================================================= */

.main-content {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.page-subtitle {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.page-actions {
  display: flex;
  gap: 7px;
}

/* =========================================================================
 * HAMBURGER BUTTON (hidden on desktop, shown on mobile via responsive.css)
 * ========================================================================= */

.hamburger-btn {
  display: none; /* shown on mobile via responsive.css */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 0;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s;
}

.hamburger-btn:hover,
.hamburger-btn:active {
  background: rgba(255, 255, 255, .22);
}

.hamburger-line {
  display: block;
  width: 16px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: transform .25s, opacity .15s;
}

/* Animated X when sidebar is open */
body.mobile-sidebar-open .hamburger-line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
body.mobile-sidebar-open .hamburger-line:nth-child(2) {
  opacity: 0;
}
body.mobile-sidebar-open .hamburger-line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* =========================================================================
 * MOBILE SIDEBAR BACKDROP
 * ========================================================================= */

.mobile-sidebar-backdrop {
  display: none; /* shown on mobile when open */
  position: fixed;
  inset: 0;
  z-index: 149;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}

body.mobile-sidebar-open .mobile-sidebar-backdrop {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================================
 * MOBILE SIDEBAR HEADER (close btn + project selector — hidden on desktop)
 * ========================================================================= */

.mobile-sidebar-header {
  display: none; /* shown on mobile via responsive.css */
}

.mobile-sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px;
}

.mobile-sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--mm-lichtgrau);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .15s, color .15s;
}

.mobile-sidebar-close:hover,
.mobile-sidebar-close:active {
  background: var(--border);
  color: var(--text);
}

/* ── Mobile Project Selector ── */

.mobile-project-selector {
  padding: 4px 12px 10px;
  border-bottom: 1px solid var(--border);
}

.mobile-project-label {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-light);
  margin-bottom: 4px;
  display: block;
}

.mobile-project-current {
  font-size: .82rem;
  font-weight: 600;
  color: var(--mm-topas);
  padding: 6px 8px;
  background: rgba(0, 136, 146, .06);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
}

.mobile-project-list {
  display: none; /* toggled via JS */
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.mobile-project-list.open {
  display: block;
}

.mobile-project-item {
  display: block;
  padding: 8px 10px;
  font-size: .78rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}

.mobile-project-item:last-child {
  border-bottom: none;
}

.mobile-project-item:hover,
.mobile-project-item:active {
  background: var(--mm-lichtgrau);
}

.mobile-project-item.active {
  background: rgba(0, 136, 146, .08);
  color: var(--mm-topas);
  font-weight: 600;
}
