@tailwind base;
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  /* Fix -webkit-text-size-adjust parsing error */
  html {
    -webkit-text-size-adjust: 100%;
  }
}

@layer components {
  /* Button Base Styles */
  .btn {
    @apply inline-flex items-center rounded-md px-3 py-2 text-sm font-semibold shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors duration-200;
  }

  /* Button Variants */
  .btn-primary {
    @apply btn bg-indigo-600 text-white hover:bg-indigo-700 focus:ring-indigo-500;
  }

  .btn-secondary {
    @apply btn bg-white text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:ring-indigo-500;
  }

  .btn-success {
    @apply btn bg-green-600 text-white hover:bg-green-700 focus:ring-green-500;
  }

  .btn-danger {
    @apply btn bg-red-600 text-white hover:bg-red-700 focus:ring-red-500;
  }

  .btn-warning {
    @apply btn bg-yellow-600 text-white hover:bg-yellow-700 focus:ring-yellow-500;
  }

  .btn-info {
    @apply btn bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500;
  }

  /* Button Sizes */
  .btn-sm {
    @apply px-2.5 py-1.5 text-xs;
  }

  .btn-lg {
    @apply px-4 py-2.5 text-base;
  }

  /* Icon Buttons */
  .btn-icon {
    @apply btn p-2;
  }

  /* Badge Styles */
  .badge {
    @apply inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium;
  }

  .badge-primary {
    @apply badge bg-indigo-100 text-indigo-800;
  }

  .badge-success {
    @apply badge bg-green-100 text-green-800;
  }

  .badge-warning {
    @apply badge bg-yellow-100 text-yellow-800;
  }

  .badge-danger {
    @apply badge bg-red-100 text-red-800;
  }

  .badge-info {
    @apply badge bg-blue-100 text-blue-800;
  }

  .badge-secondary {
    @apply badge bg-gray-100 text-gray-800;
  }

  /* Card Styles */
  .card {
    @apply bg-white shadow-sm rounded-lg overflow-hidden;
  }

  .card-header {
    @apply px-4 py-5 sm:px-6 border-b border-gray-200;
  }

  .card-body {
    @apply px-4 py-5 sm:p-6;
  }

  .card-footer {
    @apply px-4 py-3 sm:px-6 bg-gray-50 border-t border-gray-200;
  }

  /* Form Styles */
  .form-input {
    @apply block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm;
  }

  .form-label {
    @apply block text-sm font-medium text-gray-700;
  }

  .form-error {
    @apply mt-1 text-sm text-red-600;
  }
}

/* Screen reader only class for accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Toast animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.3s ease-out forwards;
}

.animate-fade-out-down {
  animation: fadeOutDown 0.3s ease-in forwards;
}

/* Custom animations */
.rotate-180 {
  transform: rotate(180deg);
}

/* Smooth transitions */
.transition-all {
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

.transition-transform {
  transition-property: transform;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* For the accordion content */
[data-github-log-target="changesContainer"] {
  transition: max-height 0.3s ease-in-out;
  overflow: hidden;
}

/* Toggle B */
.dot {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
input:checked ~ .dot {
  transform: translateX(100%);
  background-color: white;
}

/* Enhanced navbar styles */
html {
  scroll-behavior: smooth;
}

/* Smooth scrolling with offset for sticky navbar */
@supports (scroll-behavior: smooth) {
  html {
    scroll-padding-top: 4rem; /* Accounts for sticky navbar height */
  }
}

/* Backdrop blur support */
@supports (backdrop-filter: blur(12px)) {
  .backdrop-blur-md {
    backdrop-filter: blur(12px);
  }
}

/* Enhanced dropdown animations */
[data-dropdown-target="menu"] {
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: top;
}

[data-dropdown-target="menu"].hidden {
  transform: scale(0.95) translateY(-10px);
  opacity: 0;
}

[data-dropdown-target="menu"]:not(.hidden) {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Enhanced mobile menu animations */
#mobile-menu {
  transition: all 0.2s ease-out;
}

/* Enhanced navbar link hover states */
.navbar-link {
  position: relative;
  overflow: hidden;
}

.navbar-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.navbar-link:hover::before {
  left: 100%;
}

@media screen and (max-width: 768px) {
  #conversation_list {
      width: 80%;
      position: fixed;
      top: 0;
      left: -100%;
      z-index: 10;
      background-color: white;
      height: 100vh;
      overflow-y: auto;
  }
  
  #conversation_list.active {
      padding-top: 100px;
      left: 0;
  }
  }

/* Turbo busy indicator for agreements results */
#agreement_results [data-loading-indicator] {
  display: none;
}

#agreement_results[busy] [data-loading-indicator] {
  display: block;
}

/* Toastr Notification Styles - Override old IE filter syntax */
#toast-container {
  position: fixed;
  z-index: 999999;
}

/* Override toastr's old IE filter syntax with modern opacity */
#toast-container > div {
  opacity: 0.8 !important;
  filter: none !important;
  -ms-filter: none !important;
}

#toast-container > div:hover {
  opacity: 1 !important;
  filter: none !important;
  -ms-filter: none !important;
}

.toast-progress {
  opacity: 0.4 !important;
  filter: none !important;
  -ms-filter: none !important;
}

.toast-close-button {
  opacity: 0.8 !important;
  filter: none !important;
  -ms-filter: none !important;
}

.toast-close-button:hover,
.toast-close-button:focus {
  opacity: 0.4 !important;
  filter: none !important;
  -ms-filter: none !important;
}

#toast-container * {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

#toast-container > div {
  position: relative;
  overflow: hidden;
  margin: 0 0 6px;
  padding: 15px 15px 15px 50px;
  width: 300px;
  -moz-border-radius: 3px 3px 3px 3px;
  -webkit-border-radius: 3px 3px 3px 3px;
  border-radius: 3px 3px 3px 3px;
  background-position: 15px center;
  background-repeat: no-repeat;
  -moz-box-shadow: 0 0 12px #999999;
  -webkit-box-shadow: 0 0 12px #999999;
  box-shadow: 0 0 12px #999999;
  color: #FFFFFF;
  opacity: 0.8;
  -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
  filter: alpha(opacity=80);
}

#toast-container > div.rtl {
  direction: rtl;
  padding: 15px 50px 15px 15px;
  background-position: right 15px center;
}

#toast-container > div:hover {
  -moz-box-shadow: 0 0 12px #000000;
  -webkit-box-shadow: 0 0 12px #000000;
  box-shadow: 0 0 12px #000000;
  opacity: 1;
  -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
  filter: alpha(opacity=100);
  cursor: pointer;
}

#toast-container > .toast-info {
  background-color: #2F96B4;
}

#toast-container > .toast-error {
  background-color: #BD362F;
}

#toast-container > .toast-success {
  background-color: #51A351;
}

#toast-container > .toast-warning {
  background-color: #F89406;
}

#toast-container.toast-top-right {
  top: 12px;
  right: 12px;
}

#toast-container.toast-bottom-right {
  right: 12px;
  bottom: 12px;
}

#toast-container.toast-bottom-left {
  bottom: 12px;
  left: 12px;
}

#toast-container.toast-top-left {
  top: 12px;
  left: 12px;
}

#toast-container.toast-top-center {
  top: 12px;
  left: 50%;
  margin-left: -150px;
}

#toast-container.toast-bottom-center {
  bottom: 12px;
  left: 50%;
  margin-left: -150px;
}

#toast-container.toast-top-full-width {
  top: 12px;
  right: 0;
  left: 0;
}

#toast-container.toast-bottom-full-width {
  bottom: 12px;
  right: 0;
  left: 0;
}

#toast-container.toast-top-full-width > div,
#toast-container.toast-bottom-full-width > div {
  width: 96%;
  margin-left: auto;
  margin-right: auto;
}

.toast {
  background-color: #030303;
}

.toast-success {
  background-color: #51A351;
}

.toast-error {
  background-color: #BD362F;
}

.toast-info {
  background-color: #2F96B4;
}

.toast-warning {
  background-color: #F89406;
}

.toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  background-color: #000000;
  opacity: 0.4;
  -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);
  filter: alpha(opacity=40);
}

@-webkit-keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@-webkit-keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.toast-title {
  font-weight: bold;
}

.toast-message {
  -ms-word-wrap: break-word;
  word-wrap: break-word;
}

.toast-message a,
.toast-message label {
  color: #FFFFFF;
}

.toast-message a:hover {
  color: #CCCCCC;
  text-decoration: none;
}

.toast-close-button {
  position: relative;
  right: -0.3em;
  top: -0.3em;
  float: right;
  font-size: 20px;
  font-weight: bold;
  color: #FFFFFF;
  -webkit-text-shadow: 0 1px 0 #ffffff;
  text-shadow: 0 1px 0 #ffffff;
  opacity: 0.8;
  -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
  filter: alpha(opacity=80);
  line-height: 1;
}

.toast-close-button:hover,
.toast-close-button:focus {
  color: #000000;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.4;
  -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);
  filter: alpha(opacity=40);
}

.rtl .toast-close-button {
  left: -0.3em;
  float: left;
  right: 0.3em;
}

button.toast-close-button {
  padding: 0;
  cursor: pointer;
  background: transparent;
  border: 0;
  -webkit-appearance: none;
}