/* ============================================
   Common Universal Styles - Syntheal
   ============================================ */

/* === Global Reset & Base === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* ChatGPT-inspired color scheme */
  --bg-primary: #212121;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --bg-hover: #3e3e3e;
  --text-primary: #ececec;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --accent-primary: #10a37f;
  --accent-hover: #0d8d6f;
  --accent-secondary: #00d4ff;
  --border-color: #404040;
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* === Loading Spinner === */
.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.spinner-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === Toast Notifications === */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(120%);
  opacity: 0;
  animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  border-left: 4px solid;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent-primary);
  animation: progress 3s linear forwards;
}

.toast.success {
  border-left-color: var(--success);
}
.toast.error {
  border-left-color: var(--error);
}
.toast.warning {
  border-left-color: var(--warning);
}
.toast.info {
  border-left-color: var(--accent-secondary);
}

@keyframes slideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes progress {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.toast-message {
  font-size: 13px;
  color: var(--text-secondary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.toast-close:hover {
  color: var(--text-primary);
}

/* === Buttons === */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--accent-primary);
  color: var(--accent-primary);
}

.btn-outline:hover {
  background: var(--accent-primary);
  color: white;
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* === Input Fields === */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(8px);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  opacity: 0;
  transition: transform var(--transition), opacity var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1);
  opacity: 1;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* === Fade In Animation === */
.fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === App Container === */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
}

/* === Sidebar Styles === */
.sidebar {
  width: 260px;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

.sidebar-content {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-search {
  padding: 0 12px 12px;
  margin-bottom: 8px;
}

.sidebar-search-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.sidebar-search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

.sidebar-search-input::placeholder {
  color: var(--text-tertiary);
}

.history-section {
  margin-bottom: 16px;
}

.history-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  padding: 0 12px;
}

.sidebar-history-item {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.sidebar-history-item:hover {
  background: var(--bg-hover);
}

.sidebar-history-title {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-history-time {
  font-size: 12px;
  color: var(--text-tertiary);
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.user-avatar:empty {
  display: none;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.btn-block {
  width: 100%;
}

/* Sidebar Icon Styles */
.nav-icon {
  font-size: 18px;
  opacity: 0.7;
  filter: grayscale(0.3) brightness(0.9);
  transition: opacity var(--transition), filter var(--transition);
}

.nav-icon:empty {
  display: none;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  opacity: 1;
  filter: grayscale(0) brightness(1);
}

/* === Modal Styles for Pages === */
.modal-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(8px);
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.3s ease-out;
}

.modal-content.modal-large {
  max-width: 800px;
}

.modal-content.modal-user-menu {
  max-width: 800px;
  width: 90%;
  height: 540px;
  max-height: 540px;
}

.modal-body-split {
  display: flex;
  padding: 0;
  max-height: calc(540px - 70px);
  overflow: hidden;
  height: calc(540px - 70px);
}

.modal-sidebar {
  width: 200px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.modal-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.modal-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 100%;
  text-align: left;
}

/* Mobile Full Screen Modal */
@media (max-width: 768px) {
  .modal-content.modal-user-menu {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .modal-body-split {
    flex-direction: column;
    max-height: calc(100vh - 70px);
    height: calc(100vh - 70px);
    position: relative;
    padding: 4px;
  }

  .modal-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: none;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    background: transparent;
  }

  .modal-sidebar.hide-tabs {
    display: none;
  }

  .modal-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 8px 0;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    flex: 1;
  }

  .modal-nav-item {
    width: 95%;
    margin: 0 auto 12px auto;
    justify-content: flex-start;
    padding: 18px 20px;
    border-radius: 5px;
    text-align: left;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    font-size: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
  }

  .modal-nav-item:last-child {
    margin-bottom: 0;
  }

  .modal-nav-item:hover {
    background: var(--bg-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
  }

  .modal-nav-item.active {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
  }

  .modal-nav-item .nav-icon {
    display: inline-block;
    margin-right: 12px;
  }

  .modal-nav-item .nav-text {
    font-size: 16px;
    font-weight: 500;
  }

  .modal-content-area {
    width: 100%;
    padding: 0;
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    overflow-y: auto;
  }

  .modal-content-area.show-content {
    display: block;
  }

  .modal-content-area .content-section {
    padding: 0;
    height: 100%;
  }

  .modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: none;
    align-items: center;
    gap: 12px;
  }

  .modal-header.show-back {
    display: flex;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
    justify-content: space-between;
  }

  .modal-header.show-back .modal-close {
    display: flex;
  }

  .modal-header h2 {
    font-size: 20px;
    margin: 0;
    flex: 1;
    display: none;
  }

  .modal-header.show-back h2 {
    display: none;
  }

  .modal-back-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
    line-height: 1;
    min-width: 40px;
    height: 40px;
  }

  .modal-header.show-back .modal-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .modal-back-btn:hover {
    background: var(--bg-hover);
  }

  .modal-back-btn:active {
    transform: scale(0.95);
  }

  .modal-close {
    width: 36px;
    height: 36px;
    font-size: 24px;
  }

  .modal-nav-footer {
    border-top: none;
    padding: 0;
    margin-top: auto;
  }

  .modal-nav-footer .btn {
    width: 100%;
    margin: 1rem auto;
    border-radius: 5px;
    padding: 18px 20px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  }

  .modal-nav-footer .btn:hover {
    background: var(--bg-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
  }
}

.modal-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-nav-item.active {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
}

.modal-nav-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.modal-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px;
  background: var(--bg-secondary);
  height: 100%;
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
}

/* Support section specific styles - ensure input is always visible */
#section-support {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

#section-support #supportContent {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.user-dropdown-icon {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-tertiary);
  transition: transform var(--transition);
}

.user-info {
  cursor: pointer;
  transition: background var(--transition);
  border-radius: 8px;
  padding: 8px;
}

.user-info:hover {
  background: var(--bg-hover);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  max-height: calc(85vh - 70px);
  overflow-y: auto;
}

/* === Utilities === */
.text-center {
  text-align: center;
}
.text-left {
  text-align: left;
}
.text-right {
  text-align: right;
}
.mt-1 {
  margin-top: 8px;
}
.mt-2 {
  margin-top: 16px;
}
.mt-3 {
  margin-top: 24px;
}
.mb-1 {
  margin-bottom: 8px;
}
.mb-2 {
  margin-bottom: 16px;
}
.mb-3 {
  margin-bottom: 24px;
}
.hidden {
  display: none !important;
}
.flex {
  display: flex;
}
.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* === Responsive === */
@media (max-width: 768px) {
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .toast {
    min-width: auto;
    max-width: 100%;
  }

  .modal {
    width: 95%;
  }
  .modal-body {
    padding: 4px;
  }
  .modal-header {
    padding: 12px 24px;
  }
}
