/* ==========================================================================
   WhatsApp Channel Cards - Compact Responsive Layout (GenResurs 2026)
   ========================================================================== */

/* Container queries root */
:has(> #accountsGrid),
#tab-account,
#test-shell {
  container-type: inline-size;
}

#accountsGrid {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 16px;
  align-items: start !important;
  width: 100%;
}

@container (min-width: 900px) {
  #accountsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 18px;
  }
}

@supports not (container-type: inline-size) {
  @media (min-width: 1280px) {
    #accountsGrid {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      gap: 18px;
    }
  }
}

#accountsGrid > .gold-major-block {
  height: auto !important;
  display: flex;
  flex-direction: column;
}

#accountsGrid .premium-account {
  flex: 0 1 auto !important;
  display: flex;
  flex-direction: column;
  justify-content: flex-start !important;
  height: auto !important;
  padding: 14px 15px !important;
  gap: 8px !important;
  box-sizing: border-box;
  background: radial-gradient(ellipse at 10% 0%, rgba(255, 255, 255, 0.05), transparent 55%), linear-gradient(135deg, #18191f, #0d0f14 70%);
  border: 1px solid rgba(212, 175, 55, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

/* Thin Elegant Divider */
.card-compact-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.25), rgba(255, 255, 255, 0.08) 50%, rgba(212, 175, 55, 0.25));
  margin: 1px 0;
  flex-shrink: 0;
}

/* ==========================================================================
   Section 1: Compact Header (Account Name, Phone, Status, Profile)
   ========================================================================== */

.compact-card-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding-left: 0;
  box-sizing: border-box;
}

.compact-card-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0 36px;
  box-sizing: border-box;
  text-align: center;
}

.compact-card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  color: #ffffff;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
  text-align: center;
}

.compact-card-email-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-size: 12px;
  line-height: 1.35;
  color: #a0aec0;
  padding: 0 4px;
  margin-top: -2px;
  margin-bottom: 2px;
  text-align: center;
  flex-wrap: wrap;
}

.compact-card-email-label {
  font-size: 11.5px;
  font-weight: 500;
  color: #8696a0;
  flex-shrink: 0;
}

.compact-card-email-value {
  font-size: 12px;
  font-weight: 600;
  color: #d1d7db;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-all;
  min-width: 0;
}

.compact-card-email-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  line-height: 1.2;
  flex-shrink: 0;
}

.compact-card-email-badge.unverified {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.compact-card-email-badge.verified {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.compact-card-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  box-sizing: border-box;
  flex-wrap: wrap;
}

@container (min-width: 380px) {
  .compact-card-topbar {
    flex-wrap: nowrap !important;
  }
}

@media (min-width: 500px) {
  .compact-card-topbar {
    flex-wrap: nowrap !important;
  }
}

.compact-header-main {
  display: flex;
  align-items: center;
  gap: 6px 14px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding-left: 0;
  box-sizing: border-box;
  flex-wrap: wrap;
}

@container (min-width: 380px) {
  .compact-header-main {
    flex-wrap: nowrap !important;
  }
}

@media (min-width: 500px) {
  .compact-header-main {
    flex-wrap: nowrap !important;
  }
}

.account-rename-button {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(217, 199, 140, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #dfd9c7;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.account-rename-button:hover {
  background: rgba(244, 217, 34, 0.2);
  color: #ffe735;
}

.compact-header-phone-row {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex: 0 0 auto !important;
  width: auto !important;
  font-size: 13.5px;
  line-height: 1.35;
  min-width: 0;
  box-sizing: border-box;
}

.compact-header-phone-row span {
  max-width: 100%;
  box-sizing: border-box;
}

.compact-photo {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #202c33;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.compact-profile-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.35;
  color: #c9d1d9;
  min-width: 0;
  flex: 0 1 auto;
  flex-wrap: nowrap;
}

@container (max-width: 379px) {
  .compact-profile-row {
    flex-wrap: wrap;
  }
}

.compact-row-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex-shrink: 0;
}

.compact-row-icon.icon-wa {
  background: rgba(37, 211, 102, 0.15);
  border: 1px solid rgba(37, 211, 102, 0.35);
  color: #25D366;
}

.compact-row-label {
  font-size: 14px;
  font-weight: 500;
  color: #8696a0;
  white-space: nowrap;
}

.channel-profile-value {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  min-width: 0;
  flex: 1 1 auto;
}

.compact-owner-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: #b9b6be;
  min-width: 0;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.compact-header-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* ==========================================================================
   Section 2: Telephony & Device States (Compact)
   ========================================================================== */

.compact-telephony-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  min-width: 0;
}

.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.compact-sip-row {
  padding: 1px 0;
}

.compact-sip-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.compact-row-icon.icon-sip {
  background: rgba(244, 217, 34, 0.15);
  border: 1px solid rgba(244, 217, 34, 0.35);
  color: #f4d922;
}

.channel-sip-text {
  font-size: 14px;
  color: #c9d1d9;
  font-weight: 500;
  white-space: normal;
}

.channel-sip-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  color: #ffe735;
  margin-left: 3px;
  letter-spacing: 0.5px;
}

.compact-route-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
}

.channel-call-route {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  flex-wrap: wrap;
  white-space: normal;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.channel-call-route.route-external {
  background: rgba(23, 37, 84, 0.7);
  border: 1px solid rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

.channel-call-route.route-browser {
  background: rgba(59, 7, 100, 0.7);
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #e9d5ff;
}

.channel-call-route.route-none {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(100, 116, 139, 0.4);
  color: #94a3b8;
}

/* Device rows */
.channel-device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  flex-wrap: wrap;
  padding: 2px 0;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.compact-device-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
  cursor: default;
}

.compact-row-icon.icon-external {
  background: rgba(30, 58, 138, 0.45);
  border: 1px solid rgba(59, 130, 246, 0.45);
  color: #60a5fa;
}

.compact-row-icon.icon-browser {
  background: rgba(88, 28, 135, 0.45);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #c084fc;
}

.channel-device-title {
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  min-width: 0;
}

/* Badge (CARD-01 preserved) */
.channel-device-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  box-sizing: border-box;
  flex: 0 1 auto;
  max-width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

.channel-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.channel-badge-text {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  min-width: 0;
  flex: 1 1 auto;
}

/* Status variants */
.channel-status-registered {
  color: #34d399;
  background: rgba(6, 78, 59, 0.45);
  border-color: rgba(16, 185, 129, 0.5);
}
.channel-dot-registered {
  background-color: #10b981;
}

.channel-status-unregistered {
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(71, 85, 105, 0.45);
}
.channel-dot-unregistered {
  background-color: #64748b;
}

.channel-status-unverified {
  color: #6ee7b7;
  background: rgba(6, 78, 59, 0.35);
  border-color: rgba(52, 211, 153, 0.4);
}
.channel-dot-unverified {
  background-color: #34d399;
}

.channel-status-unknown {
  color: #fde047;
  background: rgba(113, 63, 18, 0.35);
  border-color: rgba(234, 179, 8, 0.45);
}
.channel-dot-unknown {
  background-color: #eab308;
}

.channel-status-unreachable {
  color: #fca5a5;
  background: rgba(136, 19, 55, 0.4);
  border-color: rgba(244, 63, 94, 0.45);
}
.channel-dot-unreachable {
  background-color: #f43f5e;
}

/* ==========================================================================
   Section 3: Contacts (Compact)
   ========================================================================== */

.compact-contacts-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.compact-contacts-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  cursor: pointer;
  min-width: 0;
}

.compact-contacts-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.compact-contacts-title {
  font-size: 14px;
  font-weight: 700;
  color: #f6f6f8;
  line-height: 1.3;
}

.compact-contacts-desc {
  font-size: 14px;
  color: #8696a0;
  line-height: 1.3;
  margin: 0;
}

.compact-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 5px;
  border: 1px solid rgba(86, 126, 150, 0.6);
  background: #111b21;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}
.compact-checkbox:checked {
  background: #10ac91;
  border-color: #76ecda;
}
.compact-checkbox:checked:after {
  content: '✓';
  display: block;
  color: white;
  text-align: center;
  font-size: 14px;
  line-height: 1;
}

.compact-contact-result {
  font-size: 12px;
  color: #a5acc2;
}

/* ==========================================================================
   Section 4: PBX Button & Actions (Compact)
   ========================================================================== */

.compact-footer-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.compact-pbx-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: #e6f9ff;
  background: linear-gradient(135deg, rgba(9, 44, 76, 0.7), rgba(4, 25, 45, 0.85));
  border: 1px solid rgba(0, 186, 204, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}
.compact-pbx-button:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 14px rgba(0, 186, 204, 0.3);
}

.compact-button-arrow {
  margin-left: auto;
  font-size: 12px;
  color: #53dfff;
}

.compact-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding-right: 36px; /* avoid bottom-right corner chamfer */
}

.compact-action-btn {
  flex: 1 1 auto;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(104, 102, 117, 0.4);
  background: linear-gradient(135deg, #1f1f28, #15151c);
  color: #f1eff8;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.compact-action-btn:hover {
  filter: brightness(1.2);
  border-color: #b8b1c7;
}

.compact-action-btn.action-qr {
  color: #ffe448;
  background: linear-gradient(130deg, rgba(101, 82, 22, 0.6), #36301a);
  border-color: #bca335;
}

.compact-action-btn.action-delete {
  flex: 0 0 34px;
  padding: 6px;
  color: #e8a3b1;
  background: linear-gradient(140deg, #492c37, #231b27);
  border-color: rgba(132, 82, 99, 0.5);
}

/* Add WhatsApp Account Modal (scoped compact-create overlay) */
#modalAddAccount.compact-create-overlay:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
}
#modalAddAccount {
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(7px);
  overflow-y: auto;
}
.compact-create-card {
  position: relative;
  width: min(100%, 580px);
  height: auto;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  margin: auto;
  border: 1px solid #777581;
  border-radius: 22px;
  background: radial-gradient(ellipse at 0 0, #34333c77, transparent 65%), linear-gradient(135deg, #1c1b22, #101015);
  box-shadow: 0 24px 80px #0009, inset 0 1px #ffffff18;
  padding: 26px 28px 24px;
  color: #f7f6f8;
  box-sizing: border-box;
}
.compact-create-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.compact-create-header h1 {
  font-size: 23px;
  font-weight: 750;
  line-height: 1.25;
  margin: 0;
}
.compact-create-header em {
  font-style: normal;
  color: #ffe337;
}
.compact-create-header p {
  font-size: 12px;
  line-height: 1.5;
  color: #9996a5;
  margin: 7px 0 0;
}
.compact-create-close {
  width: 31px;
  height: 31px;
  border: 1px solid #77718433;
  background: #ffffff04;
  color: #bbb7c7;
  display: grid;
  place-items: center;
  border-radius: 9px;
  flex-shrink: 0;
  cursor: pointer;
}
.compact-create-close:hover {
  color: #fff;
  border-color: #9996a5;
}
.compact-create-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #c9c5d0;
  margin-bottom: 6px;
}
.compact-create-input {
  display: flex;
  align-items: center;
  gap: 13px;
  height: 44px;
  border: 1px solid #77758c;
  border-radius: 11px;
  padding: 0 14px;
  background: linear-gradient(110deg, #32313d88, #1a1a22);
  box-shadow: inset 0 1px #ffffff15;
}
.compact-create-input input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: #f2f0f6;
  font-size: 13px;
}
.compact-create-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  align-items: stretch;
}
.compact-create-submit {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 14px;
  min-height: 44px;
  border: 1px solid #ffee78;
  border-radius: 11px;
  background: linear-gradient(115deg, #fff044, #ffd015);
  color: #171408;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}
.compact-create-cancel {
  padding: 10px 21px;
  min-height: 44px;
  border: 1px solid #5d596b;
  border-radius: 11px;
  background: linear-gradient(135deg, #27252e, #14141c);
  color: #ddd9e7;
  font-size: 13px;
  cursor: pointer;
}

/* Server selection styles inside #modalAddAccount */
.server-select-group {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.server-select-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #c9c5d0;
  margin-bottom: 2px;
  gap: 8px;
  flex-wrap: wrap;
}
.server-option-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid #4a4856;
  background: linear-gradient(135deg, rgba(38, 36, 46, 0.75), rgba(22, 21, 28, 0.85));
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  box-sizing: border-box;
}
.server-option-card:hover:not(.disabled) {
  border-color: #ffd84a;
  background: linear-gradient(135deg, rgba(58, 54, 68, 0.85), rgba(28, 26, 36, 0.95));
}
.server-option-card.selected {
  border-color: #ffd015;
  background: linear-gradient(135deg, rgba(75, 65, 25, 0.55), rgba(35, 30, 15, 0.75));
  box-shadow: 0 0 16px rgba(255, 208, 21, 0.18), inset 0 1px rgba(255, 255, 255, 0.12);
}
.server-option-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: #34323e;
  background: rgba(18, 17, 23, 0.6);
}
.server-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.server-option-name {
  font-size: 13px;
  font-weight: 600;
  color: #f2f0f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-option-card.selected .server-option-name {
  color: #ffe337;
}
.server-option-sub {
  font-size: 11px;
  color: #9996a5;
  line-height: 1.3;
}
.server-option-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.server-badge-avail {
  background: rgba(0, 168, 132, 0.15);
  color: #00d6ad;
  border: 1px solid rgba(0, 168, 132, 0.3);
}
.server-badge-full {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.server-badge-auto {
  background: rgba(255, 216, 74, 0.15);
  color: #ffd84a;
  border: 1px solid rgba(255, 216, 74, 0.3);
}

@media (max-width: 520px), (max-height: 540px) {
  #modalAddAccount {
    padding: 12px;
    align-items: flex-start;
  }
  .compact-create-card {
    padding: 18px 16px 16px;
    border-radius: 16px;
    max-height: calc(100dvh - 24px);
  }
  .compact-create-header {
    margin-bottom: 14px;
  }
  .compact-create-header h1 {
    font-size: 18px;
  }
  .compact-create-actions {
    flex-direction: column;
    gap: 10px;
  }
  .server-option-card {
    flex-wrap: wrap;
    padding: 10px 12px;
  }
  .server-option-name {
    white-space: normal;
    word-break: break-word;
  }
}
