/* 2R AI - Responsive layout improvements */

html, body {
  width: 100%;
  max-width: 100%;
}

header, nav, main, .chat, .input-area {
  min-width: 0;
}

nav {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-actions {
  flex-wrap: wrap;
}

.message {
  unicode-bidi: plaintext;
}

.input-area textarea {
  min-width: 0;
  width: 100%;
}

#filePreview {
  max-width: 100%;
  overflow-wrap: anywhere;
}

@media (max-width: 600px) {
  header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px !important;
  }

  .header-logo {
    justify-content: center;
  }

  header nav {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
  }

  header nav > a {
    white-space: normal;
    text-align: center;
  }

  #language {
    max-width: 100%;
    min-height: 40px;
  }

  .auth-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
  }

  .auth-actions button {
    min-width: 0;
    max-width: 100%;
    min-height: 42px;
    padding: 9px 12px !important;
    overflow-wrap: anywhere;
  }

  main {
    min-width: 0;
  }

  .chat {
    min-height: 280px;
  }

  .messages {
    min-height: 180px !important;
    max-width: 100%;
  }

  .message {
    max-width: 94%;
    line-height: 1.6;
  }

  .input-area {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 7px;
    padding: 9px !important;
  }

  #attachBtn {
    flex: 0 0 44px;
    padding: 0 !important;
  }

  #prompt {
    flex: 1 1 120px;
    min-width: 0;
    font-size: 16px;
  }

  #send {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 12px !important;
  }

  #filePreview {
    order: 5;
    flex: 1 1 100%;
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  #send {
    flex: 1 1 100%;
  }

  header nav > a {
    flex: 1 1 100%;
  }
}

/* 2R AI - Compact mobile header */

@media (max-width: 600px) {
  header {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 6px !important;
    padding: 7px 10px !important;
  }

  .header-logo {
    justify-content: center;
  }

  .header-logo img {
    width: 62px !important;
    height: 43px !important;
  }

  header nav {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 7px;
  }

  header nav > a {
    font-size: 12px !important;
    text-align: center;
  }

  #language {
    min-height: 38px;
    padding: 7px 9px;
  }

  .auth-actions {
    display: flex;
    width: 100%;
    justify-content: center;
    gap: 6px;
  }

  .auth-actions button {
    min-height: 38px;
    padding: 7px 10px !important;
    font-size: 12px;
  }

  .conversation-toolbar {
    margin: 8px auto !important;
  }

  .conversation-toolbar button {
    min-height: 40px;
    padding: 9px !important;
  }
}

/* 2R AI - Mobile screen height optimization */

@media (max-width: 600px) {
  header {
    gap: 4px !important;
    padding: 5px 8px !important;
  }

  .header-logo img {
    width: 48px !important;
    height: 34px !important;
  }

  .brand-hero {
    margin: 0 auto !important;
  }

  .brand-hero img {
    width: 65px !important;
  }

  main h1 {
    margin: 0 !important;
    font-size: 20px !important;
  }

  .subtitle {
    margin: 2px 0 5px !important;
  }

  .conversation-toolbar {
    margin: 5px auto !important;
    gap: 6px;
  }

  .conversation-toolbar button {
    min-height: 38px;
    font-size: 13px;
    padding: 7px !important;
  }

  .chat {
    margin-top: 5px !important;
    min-height: 220px;
  }

  .messages {
    min-height: 140px !important;
  }

  .input-area {
    padding: 7px !important;
  }
}