/* RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

/* BODY */
body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background-color: #f4f6f9;
  color: #333;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

/* HEADER */
.header {
  background: #ff7900;
  color: white;
  padding: 8px 16px;
  min-height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 70px;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.header-main {
  text-align: center;
}

.header h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.header p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.header-logo {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: #fff;
  padding: 3px;
}

.welcome-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #ff7900;
  background: #ffffff;
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}

.logout-btn {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: transparent;
  color: white;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  width: min(92vw, 360px);
  background: #fff;
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.login-card h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.login-card p {
  color: #666;
  font-size: 13px;
  margin-bottom: 12px;
}

#loginForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#loginForm input {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
}

#loginForm button {
  border: none;
  border-radius: 6px;
  padding: 10px;
  color: #fff;
  background: #ff7900;
  font-size: 14px;
  cursor: pointer;
}

#loginForm button:hover {
  opacity: 0.92;
}

.login-error {
  min-height: 16px;
  color: #dc3545;
  font-size: 12px;
}

/* SEARCH SECTION */
.search-section {
  display: flex;
  gap: 10px;
  padding: 15px;
  background: white;
  border-bottom: 1px solid #ddd;
}

.search-section input,
.search-section select {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

#searchInput {
  width: 100%;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
}

.suggestion-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 10px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
}

.suggestion-item:hover {
  background: #f4f7ff;
}

/* MAIN CONTAINER */
.container {
  display: flex;
  height: 100%;
  min-height: 0;
}

/* RESULTS PANEL */
.results-panel {
  width: 35%;
  background: #ffffff;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  padding: 15px;
  min-height: 0;
}

.results-panel h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

/* RESULT ITEM */
.result-item {
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #f9fafc;
  cursor: pointer;
  transition: 0.2s;
  border-left: 4px solid transparent;
}

.result-item:hover {
  background: #eef3ff;
}

.result-item.active {
  background: #e6f0ff;
  border-left: 4px solid #007bff;
}

.result-title {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 5px;
}

.result-category {
  font-size: 12px;
  color: #777;
}

/* DETAILS PANEL */
.details-panel {
  width: 65%;
  padding: 20px;
  overflow-y: auto;
  min-height: 0;
}

.details-panel h2 {
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1.2;
}

#detailsContent {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

/* EMPTY STATE */
.empty-state {
  color: #999;
  font-style: italic;
  margin-top: 40px;
}

/* CASE TITLE */
#caseTitle {
  font-size: 22px;
  margin-bottom: 4px;
  color: #222;
  grid-column: 1 / -1;
}

/* SECTION BLOCK */
.section {
  margin-bottom: 0;
  padding: 15px;
  background: white;
  border-radius: 10px;
  border-left: 5px solid #ff7900;
  height: 100%;
}

#detailsContent .section:first-of-type {
  grid-column: 1 / -1;
}

/* SECTION TITLES */
.section h4 {
  margin-bottom: 8px;
  font-size: 14px;
  color: #ff7900;
}

/* TEXT */
.section p {
  font-size: 14px;
  line-height: 1.5;
}

#whenToUse {
  white-space: pre-line;
}

/* LIST */
.section ul {
  padding-left: 18px;
}

.section ul li {
  margin-bottom: 5px;
  font-size: 14px;
}

/* SPECIAL COLORS PER TYPE */
.section:nth-child(2) {
  border-left-color: #007bff;
}

.section:nth-child(3) {
  border-left-color: #28a745;
}

.section:nth-child(4) {
  border-left-color: #ffc107;
}

.section:nth-child(5) {
  border-left-color: #17a2b8;
}

.section:nth-child(6) {
  border-left-color: #6f42c1;
}

.section:nth-child(7) {
  border-left-color: #dc3545;
}

/* FOOTER */
.footer {
  background: #ffffff;
  border-top: 1px solid #ddd;
  text-align: center;
  padding: 6px 10px;
  font-size: 12px;
  color: #777;
}

/* SCROLLBAR (NICE TOUCH) */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .container {
    flex-direction: column;
    height: 100%;
  }

  .results-panel {
    width: 100%;
    height: 45%;
  }

  .details-panel {
    width: 100%;
    height: 55%;
  }

  #detailsContent {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  #detailsContent {
    grid-template-columns: 1fr;
  }
}
