/**
 * Uygulama geneli açılır pencereler — style.css .modal ile uyumlu ortak kabuk.
 * Arkadaşlık, DJ, yasak, ayarlar ve mobil (layout-compact) dahil.
 * Bu dosya diğer modül CSS'lerinden SONRA yüklenmelidir (index.html).
 */

/* —— Eksik düğme varyantları (modallarda yaygın) —— */
.btn-secondary {
  background: var(--bg-light);
  color: var(--text-dark);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border-light);
  border-color: var(--text-light);
  color: var(--text-dark);
}

body.theme-dark .btn-secondary {
  background: var(--bg-light);
  border-color: var(--border);
  color: var(--text-dark);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.3;
}

.modal-body .btn-primary,
.friend-modal-body .btn-primary,
.friend-modal-footer .btn-primary,
.market-item-card .btn-primary,
.dj-request-dialog .btn-primary,
.room-ban-dialog .btn-primary {
  width: auto;
  min-width: 0;
}

.modal-body .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.modal-body .form-actions .btn {
  margin-top: 0;
  flex: 1 1 auto;
}

.modal-body .form-actions .btn-secondary {
  flex: 0 1 auto;
}

/* —— Ana modal (#modalOverlay) —— */
.modal-overlay {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  padding: 16px;
}

#modalOverlay > .modal {
  color: var(--text-dark);
  max-width: min(520px, 100%);
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-white);
  background-clip: padding-box;
  border: none;
  box-shadow:
    0 0 0 1px var(--border),
    0 20px 60px rgba(15, 23, 42, 0.18);
  isolation: isolate;
}

#modalOverlay > .modal:has(.user-settings-layout) {
  max-width: min(640px, 100%);
}

.modal-header {
  background: var(--bg-white);
  color: var(--text-dark);
  gap: 12px;
}

.modal-header > span,
.modal-header #modalTitle {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.3;
}

.modal-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-mid);
  transition: background 0.15s, color 0.15s;
}

.modal-close .icon {
  width: 20px;
  height: 20px;
}

.modal-close:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

.modal-body {
  background: var(--bg-white);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.45;
}

.modal-body .modal-hint {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.45;
}

/* Form öğeleri modal içinde auth/sohbet ile aynı */
.modal-body .form-group label {
  color: var(--text-mid);
  font-size: 13px;
  font-weight: 500;
}

.modal-body .form-group input:not([type='checkbox']):not([type='color']):not([type='radio']),
.modal-body .form-group select,
.modal-body .form-group textarea,
.modal-body select#prefPmPolicy,
.modal-body input[type='text'],
.modal-body input[type='number'],
.modal-body input[type='password'],
.modal-body input[type='search'],
.modal-body textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dark);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus,
.modal-body .form-group textarea:focus,
.modal-body select#prefPmPolicy:focus,
.modal-body input[type='text']:focus,
.modal-body input[type='number']:focus {
  border-color: var(--accent);
}

.modal-body .btn {
  font-family: inherit;
}

.modal-body .btn-primary {
  background: var(--accent);
  color: #fff;
}

.modal-body .btn-primary:hover {
  background: var(--accent-hover);
}

.modal-body .form-actions .btn {
  margin-top: 0;
}

.modal-body .settings-toggle {
  color: var(--text-dark);
  border-bottom-color: var(--border-light);
}

.modal-body .settings-toggle span {
  flex: 1;
  padding-right: 8px;
}

.modal-body .user-pref-section-title {
  color: var(--text-light);
}

/* —— Ortak kabuk: alternatif modal yapıları —— */
.friend-modal-overlay,
.dj-request-modal,
.room-ban-modal {
  z-index: var(--z-ui-overlay, 25000);
}

.friend-modal-overlay {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.friend-modal {
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-width: min(520px, 100%);
}

.friend-modal-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}

.friend-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
}

.friend-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-mid);
}

.friend-modal-close:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

.friend-modal-body {
  background: var(--bg-white);
  color: var(--text-dark);
  padding: 20px;
}

.friend-modal-footer {
  background: var(--bg-light);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}

.friend-modal-footer .btn-primary {
  background: var(--accent);
  color: #fff;
}

.dj-request-backdrop,
.room-ban-backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.dj-request-dialog,
.room-ban-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  color: var(--text-dark);
}

.dj-request-title {
  color: var(--text-dark);
  font-size: 16px;
  font-weight: 600;
}

.dj-request-dialog .btn-primary,
.room-ban-dialog .btn-primary {
  background: var(--accent);
  color: #fff;
}

.room-owner-overlay {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.room-owner-panel {
  border: 1px solid var(--border);
  color: var(--text-dark);
}

.room-owner-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
}

.room-owner-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
}

.room-owner-close {
  color: var(--text-mid);
  border-radius: var(--radius-sm);
}

.room-owner-close:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

/* —— Koyu tema —— */
body.theme-dark .modal-overlay,
body.theme-dark .friend-modal-overlay {
  background: rgba(0, 0, 0, 0.62);
}

body.theme-dark .modal,
body.theme-dark .modal-header,
body.theme-dark .modal-body,
body.theme-dark .friend-modal,
body.theme-dark .friend-modal-header,
body.theme-dark .friend-modal-body,
body.theme-dark .dj-request-dialog,
body.theme-dark .room-ban-dialog {
  background: var(--bg-white);
  border-color: var(--border);
  color: var(--text-dark);
}

body.theme-dark .friend-modal-footer {
  background: var(--bg-light);
}

body.theme-dark .modal-close:hover,
body.theme-dark .friend-modal-close:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

body.theme-dark .modal-body .form-group input:not([type='checkbox']):not([type='color']),
body.theme-dark .modal-body select,
body.theme-dark .modal-body textarea,
body.theme-dark .modal-body input[type='text'],
body.theme-dark .modal-body input[type='number'] {
  background: var(--bg-light);
  border-color: var(--border);
  color: var(--text-dark);
}

/* —— Mobil / layout-compact —— */
@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }

  .friend-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .friend-modal {
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .dj-request-modal,
  .room-ban-modal {
    align-items: flex-end;
    padding: 0 0 env(safe-area-inset-bottom, 0px);
  }

  .dj-request-dialog,
  .room-ban-dialog {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

html.layout-compact .modal-overlay {
  align-items: flex-end;
  padding: 0;
}

html.layout-compact .modal {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* —— Market / çanta tam ekran sheet (modal-ui sonrası) —— */
@media (max-width: 640px) {
  .market-shop-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .market-shop-panel {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
  }
}

html.layout-compact .market-shop-overlay {
  align-items: flex-end;
  padding: 0;
}

html.layout-compact .market-shop-panel {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.market-shop-overlay .btn-secondary,
.market-item-card .btn-secondary {
  background: var(--bg-light);
  color: var(--text-dark);
  border: 1px solid var(--border);
}

body.theme-dark .gift-picker-panel,
body.theme-dark .chip-wallet-panel,
body.theme-dark .gift-picker-header,
body.theme-dark .chip-wallet-sticky {
  background: var(--bg-white);
  border-color: var(--border);
  color: var(--text-dark);
}

body.theme-dark .gift-picker-close:hover,
body.theme-dark .chip-wallet-close:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

@media (max-width: 640px) {
  .chip-wallet-overlay,
  .gift-picker-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .chip-wallet-panel,
  .gift-picker-panel {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
  }
}
