/* EMR Layout System
 * Layout classes for EMR Application
 * Version: 1.0.0
 */

/* ========================================
 * BASE RESET & OVERRIDES
 * Override Bootstrap defaults for EMR layout
 * ======================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Reset Bootstrap container padding */
html,
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  /* Prevent page-level scrollbars */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ensure EMR app takes full height */
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========================================
 * APP CONTAINER
 * ======================================== */

.emr-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--emr-bg-main);
  font-family: var(--emr-font-family);
  font-size: var(--emr-font-size-base);
  color: var(--emr-text-primary);
  line-height: var(--emr-line-height-normal);
}

/* ========================================
 * HEADER
 * ======================================== */

.emr-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--emr-header-height);
  background-color: var(--emr-bg-panel);
  border-bottom: 1px solid var(--emr-border);
  display: flex;
  align-items: center;
  padding: 0 var(--emr-space-lg);
  gap: var(--emr-space-lg);
  z-index: var(--emr-z-fixed);
}

.emr-header__logo {
  display: flex;
  align-items: center;
  gap: var(--emr-space-sm);
  min-width: 180px;
}

.emr-header__logo-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emr-header__logo-icon svg {
  width: 32px;
  height: 32px;
  color: var(--emr-primary);
}

.emr-header__logo-text {
  font-size: var(--emr-font-size-xl);
  font-weight: var(--emr-font-weight-medium);
  color: var(--emr-text-secondary);
}

.emr-header__logo-text span {
  color: var(--emr-text-primary);
}

/* Search Bar */
.emr-header__search {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
}

.emr-search-box {
  display: flex;
  align-items: center;
  background-color: var(--emr-bg-hover);
  border-radius: var(--emr-radius-full);
  padding: 0 var(--emr-space-lg);
  height: 48px;
  transition: background-color var(--emr-transition-fast), box-shadow var(--emr-transition-fast);
}

.emr-search-box:hover {
  background-color: var(--emr-bg-main);
  box-shadow: var(--emr-shadow-sm);
}

.emr-search-box:focus-within {
  background-color: var(--emr-bg-panel);
  box-shadow: var(--emr-shadow-md);
}

.emr-search-box__icon {
  width: 24px;
  height: 24px;
  color: var(--emr-text-secondary);
  flex-shrink: 0;
}

.emr-search-box__input {
  flex: 1;
  border: none;
  background: transparent;
  padding: var(--emr-space-sm) var(--emr-space-md);
  font-size: var(--emr-font-size-md);
  color: var(--emr-text-primary);
  outline: none;
}

.emr-search-box__input::placeholder {
  color: var(--emr-text-tertiary);
}

/* Header Actions */
.emr-header__actions {
  display: flex;
  align-items: center;
  gap: var(--emr-space-xs);
}

/* ========================================
 * MAIN CONTAINER
 * ======================================== */

.emr-main {
  display: flex;
  margin-top: var(--emr-header-height);
  height: calc(100vh - var(--emr-header-height));
  overflow: hidden;
}

/* ========================================
 * MODULE NAVIGATION (Left Sidebar)
 * ======================================== */

.emr-module-nav {
  position: fixed;
  left: 0;
  top: var(--emr-header-height);
  bottom: 0;
  width: var(--emr-nav-width);
  background-color: var(--emr-bg-panel);
  border-right: 1px solid var(--emr-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--emr-space-md) 0;
  gap: var(--emr-space-xs);
  z-index: var(--emr-z-sticky);
  overflow-y: auto;
  overflow-x: hidden;
}

.emr-module-nav::-webkit-scrollbar {
  width: 0;
}

.emr-nav-item {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--emr-radius-full);
  color: var(--emr-text-secondary);
  text-decoration: none;
  transition: background-color var(--emr-transition-fast), color var(--emr-transition-fast);
  position: relative;
}

.emr-nav-item:hover {
  background-color: var(--emr-bg-hover);
  color: var(--emr-text-primary);
}

.emr-nav-item.active {
  background-color: var(--emr-bg-selected);
  color: var(--emr-primary);
}

.emr-nav-item svg {
  width: 24px;
  height: 24px;
}

.emr-nav-item__tooltip {
  position: absolute;
  left: calc(100% + var(--emr-space-sm));
  background-color: var(--emr-text-primary);
  color: var(--emr-text-inverse);
  padding: var(--emr-space-xs) var(--emr-space-sm);
  border-radius: var(--emr-radius-sm);
  font-size: var(--emr-font-size-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--emr-transition-fast), visibility var(--emr-transition-fast);
  pointer-events: none;
  z-index: var(--emr-z-tooltip);
}

.emr-nav-item:hover .emr-nav-item__tooltip {
  opacity: 1;
  visibility: visible;
}

.emr-nav-spacer {
  flex: 1;
  min-height: var(--emr-space-lg);
}

.emr-nav-divider {
  width: 32px;
  height: 1px;
  background-color: var(--emr-border);
  margin: var(--emr-space-sm) 0;
}

/* ========================================
 * CONTENT AREA
 * ======================================== */

.emr-content {
  flex: 1;
  margin-left: var(--emr-nav-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Full-width content (for admin pages, settings, etc.) */
.emr-content--full {
  padding: var(--emr-space-xxl);
}

/* Three-column layout (for patient page) */
.emr-content--three-column {
  display: flex;
  height: calc(100vh - var(--emr-header-height));
  overflow: hidden;
}

/* ========================================
 * PAGE SIDEBAR (Patient List - Page specific)
 * ======================================== */

.emr-page-sidebar {
  width: var(--emr-sidebar-width);
  min-width: var(--emr-sidebar-min-width);
  max-width: var(--emr-sidebar-max-width);
  background-color: var(--emr-bg-panel);
  border-right: 1px solid var(--emr-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  resize: horizontal;
}

.emr-page-sidebar__header {
  padding: var(--emr-space-lg);
  border-bottom: 1px solid var(--emr-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--emr-space-md);
}

.emr-page-sidebar__title {
  font-size: var(--emr-font-size-md);
  font-weight: var(--emr-font-weight-medium);
  color: var(--emr-text-primary);
}

.emr-page-sidebar__count {
  font-size: var(--emr-font-size-sm);
  color: var(--emr-text-secondary);
  background-color: var(--emr-bg-hover);
  padding: var(--emr-space-xxs) var(--emr-space-sm);
  border-radius: var(--emr-radius-full);
}

.emr-page-sidebar__search {
  padding: var(--emr-space-md) var(--emr-space-lg);
}

.emr-page-sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--emr-space-sm);
}

/* ========================================
 * MAIN CONTENT AREA (Center)
 * ======================================== */

.emr-main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background-color: var(--emr-bg-main);
  padding: var(--emr-space-xxl);
}

/* ========================================
 * PREVIEW PANEL (Right - Page specific)
 * ======================================== */

.emr-preview-panel {
  width: var(--emr-preview-width);
  min-width: var(--emr-preview-min-width);
  max-width: var(--emr-preview-max-width);
  background-color: var(--emr-bg-panel);
  border-left: 1px solid var(--emr-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  resize: horizontal;
  direction: rtl;
  /* For resize handle on left */
}

.emr-preview-panel>* {
  direction: ltr;
}

.emr-preview-panel__header {
  padding: var(--emr-space-lg);
  border-bottom: 1px solid var(--emr-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.emr-preview-panel__title {
  font-size: var(--emr-font-size-md);
  font-weight: var(--emr-font-weight-medium);
  color: var(--emr-text-primary);
}

.emr-preview-panel__content {
  flex: 1;
  overflow-y: auto;
  padding: var(--emr-space-lg);
}

.emr-preview-panel__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--emr-text-tertiary);
  text-align: center;
  padding: var(--emr-space-xxl);
}

.emr-preview-panel__empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: var(--emr-space-lg);
  opacity: 0.5;
}

/* ========================================
 * PAGE HEADER
 * ======================================== */

.emr-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--emr-space-xxl);
  gap: var(--emr-space-lg);
}

.emr-page-header__left {
  display: flex;
  align-items: center;
  gap: var(--emr-space-md);
}

.emr-page-header__title {
  font-size: var(--emr-font-size-xxl);
  font-weight: var(--emr-font-weight-normal);
  color: var(--emr-text-primary);
  margin: 0;
}

.emr-page-header__subtitle {
  font-size: var(--emr-font-size-base);
  color: var(--emr-text-secondary);
}

.emr-page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--emr-space-sm);
}

/* ========================================
 * BLANK LAYOUT (for Login page)
 * ======================================== */

.emr-blank-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--emr-bg-main);
  font-family: var(--emr-font-family);
}

.emr-blank-layout__container {
  width: 100%;
  max-width: 400px;
  padding: var(--emr-space-xxl);
}

/* ========================================
 * RESPONSIVE BREAKPOINTS
 * ======================================== */

/* Tablet */
@media (max-width: 1024px) {
  .emr-page-sidebar {
    width: 240px;
  }

  .emr-preview-panel {
    width: 280px;
  }

  .emr-main-content {
    padding: var(--emr-space-lg);
  }
}

/* Mobile */
@media (max-width: 768px) {
  .emr-module-nav {
    width: 100%;
    height: auto;
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    flex-direction: row;
    justify-content: space-around;
    border-right: none;
    border-top: 1px solid var(--emr-border);
    padding: var(--emr-space-sm);
    gap: 0;
  }

  .emr-nav-item {
    width: 40px;
    height: 40px;
  }

  .emr-nav-spacer,
  .emr-nav-divider {
    display: none;
  }

  .emr-content {
    margin-left: 0;
    margin-bottom: 60px;
  }

  .emr-content--three-column {
    flex-direction: column;
  }

  .emr-page-sidebar,
  .emr-preview-panel {
    width: 100%;
    max-width: none;
    min-width: auto;
    resize: none;
  }

  .emr-preview-panel {
    direction: ltr;
  }
}

/* ========================================
 * SCROLLBAR STYLING
 * ======================================== */

.emr-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--emr-border) transparent;
}

.emr-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.emr-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.emr-scrollbar::-webkit-scrollbar-thumb {
  background-color: var(--emr-border);
  border-radius: var(--emr-radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

.emr-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: var(--emr-border-dark);
}