@import 'base.css';

.mini-window {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  width: 100%;
  height: 100%;
  backdrop-filter: opacity(0.25);
  z-index: 99;

  &.type-top {
    align-items: flex-start;

    .window {
      border: none;
      max-height: 75%;
      min-height: 400px;
      min-width: 100vw;
      border-radius: 0em 0em 1.25em 1.25em;
      transform: translateY(-100%);
    }
  }

  &.type-middle {
    align-items: center;

    .window {
      border-radius: 1.25em;
      width: 90%;
      transform: scale(0);
    }
  }

  &.type-bottom {
    align-items: flex-end;

    .window {
      border: none;
      min-height: unset;
      max-height: 90vh;
      min-width: 100vw;
      height: auto;
      border-radius: 1.25em 1.25em 0 0;
      transform: translateY(100%);
    }
  }

  .window {
    background: var(--bg-gradient);
    border-radius: 20px;
    padding: 24px 16px 16px 16px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid #334155;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
  }

  &.type-bottom .window::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, 0%);
    background: var(--text-muted);
    width: 64px;
    height: 4px;
    border-radius: 100vmax;
    margin-top: 8px;
  }

  .window .wrapper {
    overflow-y: auto;
    overflow-x: hidden;
  }
}

label.checkmark {
  height: 20px;
  width: auto;
  aspect-ratio: 1;
  cursor: pointer;
  user-select: none;

  input {
    width: 100%;
    height: 100%;
    display: none;
  }

  .check-symbol {
    height: 100%;
    width: auto;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    transition: all 0.25s;
  }

  .check-symbol:after {
    content: "";
    position: absolute;
    height: 100%;
    width: auto;
    aspect-ratio: 1;
  }

  input:checked~.check-symbol {
    background-color: var(--accent-primary);
  }

  input:checked~.check-symbol:after {
    left: 50%;
    top: 50%;
    width: 25%;
    height: 50%;
    border: 0.16px solid white;
    border-width: 0 0.15em 0.15em 0;
    transform: translate(-50%, -50%) rotate(45deg);
  }
}

.toast {
  position: fixed;
  bottom: -5%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75em 16px;
  border-radius: 100vmax;
  background: var(--bg-tertiary);
  z-index: 100;
  transition: all 0.5s ease;
  max-width: 90%;
  width: max-content;
}

.super-badge {
  position: absolute;
  top: -0.2em;
  right: -0.2em;
  width: 3.625em;
  height: 3.625em;
  z-index: 2;
  background: var(--accent-success);
  clip-path: path("M51.8187 26.4853L28.8481 3.51472C26.5977 1.26428 23.5454 0 20.3628 0H2.1618C0.379992 0 -0.51234 2.15429 0.74759 3.41422L51.9192 54.5858C53.1791 55.8457 55.3334 54.9534 55.3334 53.1716V34.9706C55.3334 31.788 54.0691 28.7357 51.8187 26.4853Z");

  .text-box {
    transform: rotate(45deg) translate(26%, 75%);
    text-align: center;
  }

  .text-box .text {
    font-weight: 600;
    font-size: 0.6em;
    text-transform: uppercase;
  }
}

.stub {
  align-self: center;
  justify-self: center;
  text-align: center;
  height: 100%;
  width: 100%;

  .content {
    max-width: 300px;
  }

  img,
  video {
    height: 80px;
    width: 80px;
  }

  .title {
    margin-top: 0.5em;
    font-size: 1.25em;
    font-weight: 600;
  }

  .subtitle {
    color: var(--text-muted);
  }

  button {
    margin-top: 16px;
    width: 75%;
  }
}

.deal-card {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  width: 100%;
  cursor: pointer;
  transition: all 0.3s ease;

  .timer {
    background: var(--border);
    color: var(--accent-secondary);
  }

  .timer.warning {
    color: var(--accent-warning);
  }

  .timer.danger {
    color: var(--accent-danger);
  }

  .timer svg {
    height: 15px;
    width: 15px;
  }

  &[data-status="awaiting"] .badge {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
  }

  &[data-status="pending"] .status,
  &[data-status="delivered"] .status {
    background: rgba(0, 209, 255, 0.15);
    color: var(--accent-primary);
  }

  &[data-status="completed"] .status {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
  }

  &[data-status="dispute"] .status {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
  }

  &[data-status="cancelled"] .status {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
  }

  .description {
    max-height: 100px;
    overflow-y: auto;
    scrollbar-width: none;
  }

  .description::-webkit-scrollbar {
    display: none;
  }

  .ton-amount {
    font-size: 20px;
  }

  .footer .meta svg {
    width: 17px;
    height: 17px;
  }

  .footer .meta .separator {
    opacity: 0.5;
  }

  .footer .date {
    color: var(--text-muted);
  }

  &:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
  }
}

.dispute-card {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 24px 12px;
  border: 1px solid #334155;

  .header {
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
  }

  .details {
    padding: 12px;
    margin-bottom: 12px;
  }

  .details .item {
    min-width: calc(50% - 0.25em);
  }
}

.tag {
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 0.75em;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: white;
}

.ton-amount {
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
  color: var(--accent-primary);

  svg {
    height: 100%;
    width: auto;
    stroke-width: 2;
  }

  .fiat {
    color: var(--text-muted);
  }
}

.tc-button {
  color: white;

  &[connected="true"] {
    border: 1px solid var(--border);
    background: var(--bg-secondary);
  }

  &[connected="false"] {
    background: var(--gradient-primary);
  }
}

.tlw {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 16px;
  background: var(--accent-primary);
  text-wrap: nowrap;

  svg {
    fill: white;
    width: 17px;
    height: 17px;
  }

  img {
    height: 24px;
    width: 24px;
    border-radius: 50%;
  }

  .name {
    max-width: 150px;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  &[logged=true] {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
  }

  &[logged=true] svg {
    display: none;
  }

  &[logged=false] img {
    display: none;
  }
}

section.deals {
  .panel {
    background: var(--bg-secondary);
    padding: 0.5rem;
    border-radius: 12px;
    overflow-x: auto;
  }

  .panel .item {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: none;
    cursor: pointer;
    transition: all 0.3s;
  }

  .panel .item.active {
    background: var(--gradient-primary);
    box-shadow: var(--shadow-sm);
  }

  .panel .item:not(.active):hover {
    background: var(--bg-tertiary);
  }

  .wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  }

  .wrapper:has(.stub) {
    display: flex;
  }

  .wrapper .deal-card {
    height: min-content;
  }
}

section.create {
  .form-group svg {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
  }

  .timer span {
    font-size: 32px;
  }

  .note {
    color: var(--text-secondary);
    font-size: 11px;
  }
}

section.profile {

  .account,
  .stats,
  .wallet,
  .settings {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
  }

  .account {
    border: 1px solid var(--border);
  }

  .account .avatar {
    background: var(--gradient-primary);
    border-radius: 50%;
    padding: 10px;
  }

  .account .name {
    font-size: 16px;
    margin-right: 4px;
  }

  .account .info svg {
    height: 16px;
    width: 16px;
    fill: gold;
    color: gold;
    margin-right: 2px;
  }

  .account .level,
  .account .role {
    padding: 2px 8px;
    font-size: 12px;
  }

  .account .level[data-value="newbie"] {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  }

  .account .level[data-value="trader"] {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  }

  .account .level[data-value="pro"] {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
  }

  .account .level[data-value="expert"] {
    background: linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
  }

  .account .level[data-value="master"] {
    background: linear-gradient(135deg, #F97316 0%, #DC2626 100%);
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.5);
  }

  .account .level[data-value="legend"] {
    background: linear-gradient(135deg, #00D1FF 0%, #8B5CF6 50%, #FF69B4 100%);
    box-shadow: 0 0 20px rgba(0, 209, 255, 0.6);
    animation: LegendGlow 2s ease-in-out infinite alternate;
  }

  .account .role[data-value="user"] {
    background: linear-gradient(135deg, #64748B 0%, #475569 100%);
  }

  .account .role[data-value="guarant"] {
    background: linear-gradient(135deg, #F59E0B 0%, #B45309 100%);
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.5);
  }

  .account .role[data-value="admin"] {
    background: linear-gradient(135deg, #4F46E5 0%, #3730A3 100%);
    box-shadow: 0 0 12px rgba(79, 70, 229, 0.4);
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .stats .item {
    padding: 8px 0px;
  }

  .stats .item svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
  }

  .stats .item .value {
    font-size: 20px;
  }

  .stats .item .text {
    color: var(--text-muted);
    font-size: 12px;
  }

  .wallet .ton-amount .value,
  .wallet .ton-amount svg {
    color: var(--accent-primary);
  }

  .wallet .ton-amount .value {
    font-size: 24px;
  }

  .wallet .ton-amount svg {
    height: 28px;
    width: 28px;
  }

  .wallet .ton-amount .fiat {
    margin-top: auto;
  }

  .wallet .tc-button {
    width: 100%;
  }

  .wallet .tc-button {
    padding: 6px 8px;
    width: 100%;
  }

  .wallet .tc-button[connected="false"]~.deposit,
  .wallet .tc-button[connected="false"]~.withdraw {
    display: none;
  }

  .wallet .deposit,
  .wallet .withdraw {
    flex: 1;
  }

  .wallet .deposit {
    background: var(--accent-success);
  }

  .wallet .withdraw {
    background: var(--accent-danger);
  }

  .settings {
    padding: 0;
  }

  .settings .item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }

  .settings .item:last-child {
    border-bottom: none;
  }

  .settings .item .icon {
    height: 36px;
    width: 36px;
    background: rgba(0, 209, 255, 0.15);
    border-radius: 10px;
    padding: 8px;
  }

  .settings .item .action .text {
    font-size: 18px;
  }
}

section.deal {
  display: grid;
  grid-template-columns: 1fr 1fr;

  .left,
  .right {
    overflow: hidden;
    height: 100%;
  }

  .header,
  .panel,
  .review {
    padding: 16px;
  }

  .offers,
  .chat {
    max-height: calc(100vh - 9vh);
  }

  .chat {
    height: 100%;
  }

  .header .label,
  .panel .label,
  .offers .label,
  .chat .label,
  .review .label {
    font-size: 20px;
  }

  .header {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: 16px;
  }

  .header .step {
    flex: 1;
    opacity: 0.5;
  }

  .header .step::before {
    content: '';
    position: absolute;
    top: 24px;
    height: 4px;
    width: 100%;
    background: var(--border);
  }

  .header .step:first-child::before {
    left: 10%;
    width: 90%;
  }

  .header .step:last-child::before {
    right: 10%;
    width: 90%;
  }

  .header .step .icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    transition: all 0.3s ease;
  }

  .header .step[active],
  .header .step[completed] {
    opacity: 1;
  }

  .header .step[active] .icon {
    background: var(--gradient-primary);
    box-shadow: 0 0 20px rgba(0, 209, 255, 0.3);
    animation: Pulse 2s ease-in-out infinite;
  }

  .header .step[completed] .icon {
    background: var(--accent-success);
  }

  .header .step[completed]::before {
    background: var(--accent-success);
  }

  .header .step[active]::before {
    background: linear-gradient(90deg, var(--accent-success) 50%, var(--accent-primary) 50%);
  }

  &[status="dispute"] .header .step .icon {
    background: var(--accent-warning);
  }

  &[status="dispute"] .header .step::before {
    background: var(--accent-warning);
  }

  .header .table .timer .bar {
    --progress: 75%;
    height: 6px;
    background: var(--border);
    border-radius: 100vmax;
    overflow: hidden;
  }

  .header .table .bar::after {
    content: "";
    position: absolute;
    height: 100%;
    background: var(--accent-primary);
    border-radius: 100vmax;
    width: var(--progress);
  }

  .header .table .note {
    border: 1px solid var(--text-secondary);
    padding: 6px 12px;
    border-radius: 12px;
    color: var(--text-secondary);
  }

  .actions:not(:has(> button:not([style*="display: none"]))) {
    display: none;
  }

  .header .actions .share-deal {
    background: var(--accent-pink);
  }

  .header .actions .sent,
  .header .actions .sent-offer {
    background: var(--accent-primary);
  }

  .header .actions .received {
    background: var(--accent-success);
  }

  .header .actions .dispute,
  .header .actions .delete,
  .header .actions .cancel-offer {
    background: var(--accent-danger);
  }

  .header .admin-panel .backup-deal {
    background: var(--accent-warning);
    width: 100%;
  }

  .header .admin-panel .seller-side {
    background: var(--accent-seller);
    width: calc(50% - 4px);
  }

  .header .admin-panel .buyer-side {
    background: var(--accent-buyer);
    width: calc(50% - 4px);
  }

  .header .admin-panel .cancel-deal {
    background: var(--accent-danger);
    width: 100%;
  }

  .panel {
    background: var(--gradient-card);
    border-radius: 16px;
  }

  .panel .item {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }

  .panel .item:last-child {
    border-bottom: none;
  }

  .panel .item svg {
    height: 16px;
    width: 16px;
  }

  .panel .item .text {
    font-size: 12px;
  }

  .panel .item .value {
    font-size: 16px;
  }

  .panel .item:hover .text,
  .panel .item:hover svg {
    color: var(--text-primary);
  }

  .panel .item:hover .value {
    color: var(--accent-primary);
  }

  .panel .about {
    grid-column: 1 / -1;
  }

  .review {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: 16px;
  }

  .review svg.active {
    color: gold;
    fill: gold;
  }

  .review textarea {
    padding: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    height: 100px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    resize: none;
  }

  .offers {
    background: var(--gradient-card);
    border-radius: 16px;
    flex: 1;
    height: 100%;
  }

  .offers .label {
    padding: 16px 16px 0;
  }

  .offers .items {
    height: 230px;
    overflow-y: auto;
  }

  .offers .item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }

  .offers .item:last-child {
    border-bottom: none;
  }

  .offers .item .name {
    font-size: 16px;
    margin-right: 2px;
  }

  .offers .item .content svg {
    height: 18px;
    width: 18px;
  }

  .offers .item .basic svg {
    color: gold;
    fill: gold;
  }

  .offers .item .acts button {
    padding: 7px 16px;
  }

  .offers .item .acts .accept-offer {
    background: var(--accent-success);
  }

  .offers .item .acts .reject-offer {
    background: var(--accent-danger);
  }

  .offers .items:has(.item) .stub {
    display: none;
  }

  .chat {
    background: var(--gradient-card);
    border-radius: 16px;
    width: 100%;
  }

  .chat .label {
    padding: 16px;
  }

  .chat .messages {
    background: var(--bg-secondary);
    flex: 1;
    min-height: 400px;
    padding: 16px;
    overflow-y: auto;
  }

  .chat .message {
    background: var(--bg-tertiary);
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
  }

  .chat .message .text {
    overflow-wrap: break-word;
  }

  .chat .message.seller .name {
    color: var(--accent-seller);
  }

  .chat .message.buyer .name {
    color: var(--accent-buyer);
  }

  .chat .message.admin .name {
    color: var(--accent-admin);
  }

  .chat .message.system {
    align-self: center;
    background: transparent;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75em;
  }

  .message.self {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 18px;
  }

  .chat .message .date {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10px;
  }

  .chat .writter {
    padding: 16px;
  }

  .chat .writter input {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 12px;
  }

  .chat .writter .send {
    background: var(--accent-primary);
    border-radius: 16px;
    width: 40px;
    height: 40px;
  }
}

section.disputes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));

  &:has(.stub) {
    display: flex;
  }

  .deal-card {
    height: min-content;
  }
}

#modal.deposit,
#modal.withdraw {
  .fiat {
    font-size: 12px;
    color: var(--text-muted);
  }

  .form.address {
    margin-top: 8px;
  }

  button {
    margin-top: 24px;
    width: 100%;
  }
}

/* Animations */
@keyframes Pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

@keyframes LegendGlow {
  0% {
    box-shadow: 0 0 20px rgba(0, 209, 255, 0.6);
  }

  100% {
    box-shadow: 0 0 30px rgba(255, 105, 180, 0.8);
  }
}

/* Large Desktop */
@media (min-width: 1200px) {}

/* Desktop/Tablet Landscape */
@media (min-width: 992px) and (max-width: 1199px) {}

/* Tablet Portrait */
@media (min-width: 768px) and (max-width: 991px) {}

/* Mobile Landscape / Small Tablet */
@media (min-width: 640px) and (max-width: 767px) {}

/* Mobile Portrait */
@media (max-width: 639px) {

  nav .left,
  nav .right {
    display: none;
  }

  nav .center {
    width: 100%;
  }

  nav .center .item {
    padding: 8px 8px;
  }

  section {
    padding: 8px;
  }

  .deal-card {
    padding: 8px;
  }

  .badge {
    padding: 4px 8px;
  }

  section.deals .panel .item {
    padding: 8px 8px;
  }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {}