/* ========================================
   MATERIAL DESIGN 3 - BASE STYLES
   Abie Messenger
   ======================================== */

/* Import Tokens */
@import url('./tokens/colors.css');
@import url('./tokens/typography.css');
@import url('./tokens/elevation.css');
@import url('./tokens/motion.css');

/* ========================================
   CSS RESET & BOX SIZING
   ======================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ========================================
   ROOT / HTML
   ======================================== */
html {
  overflow-x: hidden;
  max-width: 100vw;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   BODY
   ======================================== */
body {
  font-family: var(--md-sys-typescale-font-family-plain);
  font-size: var(--md-sys-typescale-body-large-font-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  letter-spacing: var(--md-sys-typescale-body-large-letter-spacing);
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ========================================
   SCREENS
   ======================================== */
.screen {
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.hidden {
  display: none !important;
}

/* ========================================
   SCROLLBARS - MD3 Style
   ======================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--md-sys-color-outline);
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--md-sys-color-outline-variant) transparent;
}

/* ========================================
   SELECTION
   ======================================== */
::selection {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

/* ========================================
   FOCUS VISIBLE
   ======================================== */
:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* ========================================
   LINKS
   ======================================== */
a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  transition: color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

a:hover {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
}

/* ========================================
   BUTTONS BASE
   ======================================== */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

/* ========================================
   INPUTS BASE
   ======================================== */
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input::placeholder,
textarea::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 1;
}

/* ========================================
   IMAGES
   ======================================== */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ========================================
   STATE LAYERS - MD3 Interactive States
   ======================================== */
.md-state-layer {
  position: relative;
  overflow: hidden;
}

.md-state-layer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  pointer-events: none;
  border-radius: inherit;
}

.md-state-layer:hover::before {
  opacity: var(--md-sys-state-hover-opacity);
}

.md-state-layer:focus-visible::before {
  opacity: var(--md-sys-state-focus-opacity);
}

.md-state-layer:active::before {
  opacity: var(--md-sys-state-pressed-opacity);
}

/* ========================================
   RIPPLE EFFECT
   ======================================== */
.md-ripple {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.md-ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
  animation: md-ripple-expand 450ms var(--md-sys-motion-easing-standard) forwards;
}

@keyframes md-ripple-expand {
  0% {
    transform: scale(0);
    opacity: 0.15;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Автоматически применять ripple к интерактивным элементам */
button,
.btn-primary,
.btn-secondary,
.chat-item,
.contact-item,
.sidebar-tab,
.auth-tab,
.icon-btn,
.attach-btn,
.emoji-btn,
.chat-search-btn,
[role="button"] {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ========================================
   SURFACE STYLES
   ======================================== */
.md-surface {
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

.md-surface-container-lowest {
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
}

.md-surface-container-low {
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
}

.md-surface-container {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}

.md-surface-container-high {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.md-surface-container-highest {
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}

/* ========================================
   DIVIDERS
   ======================================== */
.md-divider {
  height: 1px;
  background: var(--md-sys-color-outline-variant);
}

.md-divider-inset {
  margin-left: 16px;
  margin-right: 16px;
}

/* ========================================
   VISUALLY HIDDEN (Accessibility)
   ======================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   Z-INDEX SCALE
   ======================================== */
:root {
  --z-index-drawer: 100;
  --z-index-app-bar: 200;
  --z-index-modal: 1000;
  --z-index-snackbar: 1100;
  --z-index-tooltip: 1200;
}
