/* ============================================================
   Rebho Account Portal - App Specific Styles
   ============================================================ */

/* ---- Platform wrapper ---- */

#platform { display: none; }

#platform,
.page-section,
.tab-content {
  min-width: 0;
  max-width: 100%;
}

/* ---- Login screen ---- */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--r-bg);
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: var(--r-radius);
  border: 1px solid var(--r-border);
  box-shadow: none;
}

.login-card .card-body { padding: 2.25rem; }

.login-brand {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--r-brand);
  letter-spacing: -0.3px;
}

#login-error {
  display: none;
  margin-top: 0.75rem;
}

/* ---- Pages ---- */

.page-section { display: none; }
.page-section.active { display: block; }

/* ---- Hero card (dashboard) ---- */

.hero-card {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  padding: var(--r-section-pad);
}

.hero-card .card-body h5 {
  font-size: 20px;
  font-weight: 600;
  color: var(--r-text);
}

.hero-card .card-body p {
  font-size: 15px;
  color: var(--r-text-secondary);
  line-height: 1.6;
}

.hero-graphic {
  width: 180px;
  flex-shrink: 0;
}

.hero-graphic svg path,
.hero-graphic svg rect,
.hero-graphic svg circle {
  stroke: var(--r-text-secondary);
}

/* ---- News carousel ---- */

#newsCarousel {
  border-radius: 0 0 var(--r-radius) var(--r-radius);
  overflow: hidden;
}

.news-slide-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

#newsCarousel .carousel-control-prev-icon,
#newsCarousel .carousel-control-next-icon {
  width: 1.1rem;
  height: 1.1rem;
  background-color: rgba(0,0,0,.45);
  border-radius: 50%;
  background-size: 55%;
  padding: 10px;
}

/* ---- App cards ---- */

.app-card {
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius);
  background: var(--r-surface);
  transition: border-color 0.15s, transform 0.15s;
  box-shadow: none;
  padding: var(--r-nested-pad);
}

.app-card:hover {
  border-color: var(--r-border-hover);
  transform: translateY(-1px);
  box-shadow: none;
}

.app-card-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.app-card .fw-semibold,
.app-card .text-dark {
  font-size: 15px;
  font-weight: 600;
  color: var(--r-text);
}

.app-card .small,
.app-card .text-muted {
  font-size: 14px;
  color: var(--r-text-secondary);
}

.app-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
}

/* ---- App drag and drop ---- */

.app-sortable {
  cursor: grab;
  transition: opacity .2s, transform .15s;
}

.app-sortable:active { cursor: grabbing; }
.app-dragging { opacity: 0.4; }

.app-drag-over .app-card {
  border: 1.5px solid var(--r-accent-border);
  transform: translateY(-1px);
}

/* ---- 2FA panel ---- */

.twofa-qr-placeholder {
  width: 140px;
  height: 140px;
  border: 1px dashed var(--r-border);
  border-radius: var(--r-radius);
  background: var(--r-nested);
}

/* ---- Account info / avatar ---- */

.account-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--r-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.5rem;
  transition: background-color .2s;
}

.avatar-edit-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--r-surface);
  background: var(--r-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0;
  transition: opacity .15s;
}

.avatar-edit-btn:hover { opacity: 0.85; }

.avatar-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
  padding: 0;
}

.avatar-color-swatch:hover { transform: scale(1.1); }

.avatar-color-swatch.avatar-color-active {
  border-color: var(--r-text);
  box-shadow: 0 0 0 2px var(--r-surface), 0 0 0 3.5px var(--r-text);
}

/* ---- Profile rows ---- */

.profile-row {
  border-left: none;
  border-right: none;
  border-color: var(--r-border);
  transition: background .1s;
  padding: 0.75rem 1.25rem;
}

.profile-row:hover {
  background: var(--r-nested);
}

.profile-row-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--r-nested);
  color: var(--r-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.profile-edit-btn {
  opacity: 0;
  transition: opacity .15s;
}

.profile-row:hover .profile-edit-btn {
  opacity: 1;
}

.profile-row-actions { flex-shrink: 0; }

.profile-row > .d-flex,
.profile-value-wrap {
  min-width: 0;
}

.profile-row .fw-medium,
.profile-row .fw-semibold,
.profile-row .text-dark {
  font-size: 15px;
  color: var(--r-text);
}

.profile-row .small,
.profile-row .text-muted {
  font-size: 14px;
  color: var(--r-text-secondary);
  overflow-wrap: anywhere;
}

.profile-row .text-body,
.profile-row [data-display]:not(.text-muted) {
  color: var(--r-text) !important;
  overflow-wrap: anywhere;
}

.profile-inline-input {
  width: auto !important;
  min-width: 60px;
  max-width: 100%;
  font-size: 14px;
}

.profile-inline-input[type="date"] { min-width: 150px; }

.phone-prefix-select {
  width: auto !important;
  min-width: 0 !important;
  max-width: 90px;
  flex: 0 0 auto !important;
  padding: .25rem .4rem .25rem .5rem !important;
  font-size: 13px;
}

.phone-input-group {
  width: auto !important;
  display: inline-flex !important;
  max-width: 100%;
}

.phone-input-group .profile-inline-input {
  min-width: 110px;
  max-width: 160px;
  flex: 0 1 auto !important;
}

/* ---- Activity log ---- */

.activity-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.activity-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.activity-filter-segment {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.25rem;
  background: var(--r-nested);
  border: 1px solid var(--r-border);
  border-radius: 999px;
  white-space: nowrap;
}

.activity-filter-btn {
  border: 0;
  background: transparent;
  color: var(--r-text-secondary);
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.activity-filter-btn:hover {
  color: var(--r-text);
}

.activity-filter-btn.is-active {
  background: var(--r-surface);
  color: var(--r-text);
  box-shadow: inset 0 0 0 1px var(--r-accent-border);
}

.activity-filter-meta {
  font-size: 13px;
  color: var(--r-text-muted);
  white-space: nowrap;
}

.activity-row {
  border-bottom: 1px solid var(--r-border);
  padding: 0.6rem 0;
}

.activity-row:last-child {
  border-bottom: none;
}

.activity-icon {
  font-size: 1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  color: var(--r-text-secondary);
}

.activity-row .fw-medium,
.activity-row .fw-semibold {
  font-size: 15px;
  color: var(--r-text);
}

.activity-row .small {
  font-size: 14px;
  color: var(--r-text-secondary);
  overflow-wrap: anywhere;
}

/* ---- Security tab ---- */

.session-card {
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-sm);
  transition: border-color .15s;
  background: var(--r-surface);
  box-shadow: none;
  padding: var(--r-nested-pad);
}

.session-card:hover {
  border-color: var(--r-border-hover);
}

.session-card-current {
  border: 1px solid var(--r-border-hover);
  background: var(--r-nested);
}

.session-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-radius-sm);
  background: var(--r-nested);
  color: var(--r-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.session-card-current .session-icon {
  background: var(--r-brand-light);
  color: var(--r-brand);
}

.session-card .fw-semibold,
.session-card .fw-medium,
.session-card .text-dark {
  font-size: 16px;
  color: var(--r-text);
}

.session-card .small {
  font-size: 14px;
  color: var(--r-text-secondary);
  overflow-wrap: anywhere;
}

.session-card .text-muted {
  font-size: 14px;
  color: var(--r-text-secondary) !important;
  overflow-wrap: anywhere;
}

.history-row {
  border-bottom: 1px solid var(--r-border);
  padding: 0.5rem 0;
}

.history-row:last-child {
  border-bottom: none;
}

.history-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--r-nested);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  color: var(--r-text-secondary);
}

.history-row .fw-medium,
.history-row .fw-semibold {
  font-size: 15px;
  color: var(--r-text);
}

.history-row .small {
  font-size: 14px;
  color: var(--r-text-secondary);
  overflow-wrap: anywhere;
}

/* ---- Billing ---- */

.billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.billing-card {
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius);
}

.billing-card-full {
  grid-column: 1 / -1;
}

.billing-table-wrap {
  max-width: 100%;
}

.billing-history-table th {
  font-size: 13px;
  color: var(--r-text-secondary);
  border-bottom-color: var(--r-border);
}

.billing-history-table td {
  font-size: 14px;
  color: var(--r-text);
  border-bottom-color: var(--r-border);
}

@media (max-width: 991.98px) {
  .profile-edit-btn { opacity: 1; }

  .profile-row.list-group-item { padding-left: 1rem; padding-right: .75rem; }
  .profile-row-icon { width: 30px; height: 30px; font-size: .8rem; }

  .profile-row > .d-flex {
    flex-wrap: wrap;
    align-items: flex-start !important;
  }

  .profile-row-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    padding-left: 2.75rem;
  }

  .profile-value-wrap {
    width: 100%;
  }

  .profile-inline-input,
  .profile-inline-input[type="date"],
  .phone-input-group,
  .phone-input-group .profile-inline-input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .phone-input-group {
    display: flex !important;
  }

  .phone-prefix-select {
    flex: 0 0 76px !important;
    max-width: 76px;
  }

  #tab-password .card-body > .d-flex.justify-content-between.align-items-start,
  #tab-security .card-body > .d-flex.justify-content-between.align-items-start {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .hero-graphic { display: none; }

  .session-card { padding: 12px 14px; }
  .session-card .d-flex { gap: .5rem !important; }

  .activity-row {
    flex-wrap: wrap;
    gap: .25rem !important;
    padding-top: .35rem !important;
    padding-bottom: .35rem !important;
  }

  .activity-row .activity-icon { font-size: .9rem; width: 22px; }
  .activity-row .flex-grow-1 .fw-medium { font-size: 13px; }
  .activity-row .flex-grow-1 .small { font-size: 12px; }

  .activity-row .text-end {
    text-align: start !important;
    width: 100%;
    padding-left: 26px;
    font-size: 12px;
  }

  .activity-row .text-end .small { display: inline; }
  .activity-row .text-end .small + .small::before { content: " . "; }

  .card-body.p-4 { padding: 1rem !important; }

  .billing-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767.98px) {
  .activity-filter-bar {
    align-items: stretch;
  }

  .activity-filter-segment {
    width: 100%;
    overflow-x: auto;
    padding-inline: 0.35rem;
  }

  .activity-filter-meta {
    width: 100%;
    white-space: normal;
  }
}

@media (max-width: 575.98px) {
  .login-card .card-body { padding: 1.5rem; }
  .login-brand { font-size: 1.15rem; }
  .account-avatar { width: 56px; height: 56px; font-size: 1.2rem; }
  .avatar-color-swatch { width: 24px; height: 24px; }

  #dash-grid {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
  }

  #dash-grid > * {
    flex: 0 0 50%;
    max-width: 50%;
  }
}