/**
 * Corporate polish + phone-first layout for imartPortal.
 * Loaded after style.css via header.php.
 */

:root {
  --corp-space-1: 8px;
  --corp-space-2: 12px;
  --corp-space-3: 16px;
  --corp-space-4: 24px;
  --corp-radius: 12px;
  --corp-touch: 44px;
}

/* ——— Header shell ——— */
header.app-header,
header {
  min-height: 64px;
  padding: 10px 20px;
  gap: 12px;
}

.header-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
}

header .header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

header .header-nav li {
  padding: 0;
}

header .header-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

header .header-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

header .header-nav a i {
  padding: 0;
  font-size: 0.95rem;
}

.header-user,
.header-signout {
  max-width: 180px;
}

.header-user-name,
.header-signout-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ——— Content rhythm ——— */
.content-wrapper {
  padding: 24px 28px 48px;
}

.page-title {
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.dashboard-welcome,
.page-lede {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 42rem;
  margin: 0 0 20px;
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.dash-card {
  padding: 18px 16px;
  border-radius: var(--corp-radius);
}

.dash-value {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.dash-android-card,
.incoming-card,
.page-form,
.sender-block,
.env-banner {
  border-radius: var(--corp-radius);
}

.dash-quick-grid {
  gap: 10px;
}

.dash-quick-link {
  min-height: var(--corp-touch);
}

/* ——— Forms & tables ——— */
.form-field label,
.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.form-field input[type=text],
.form-field input[type=password],
.form-field input[type=email],
.form-field input[type=tel],
.form-field textarea,
.form-field select,
.login-form input {
  min-height: 46px;
  border-radius: 10px;
}

.login-form {
  width: min(440px, 94vw);
  padding: 28px 24px 22px;
  border-radius: 16px;
}

.login-help-box {
  font-size: 0.82rem;
  line-height: 1.45;
}

.submit-button,
.send-button,
.dash-action-btn {
  min-height: 46px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.table-scroll {
  border: 1px solid var(--line);
  border-radius: var(--corp-radius);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  min-width: 560px;
}

/* ——— Sidebar ——— */
.menu {
  padding: 12px 12px 28px;
}

.menu ul li a {
  min-height: 44px;
  font-size: 0.9rem;
}

.reseller-logo {
  margin-bottom: 10px;
}

/* ——— Footer ——— */
.footer {
  padding: 20px 22px 28px;
  gap: 14px;
}

.footer .reseller-address {
  line-height: 1.5;
}

/* ——— Phone / small tablet ——— */
@media (max-width: 900px) {
  header.app-header,
  header {
    min-height: 56px;
    padding: 8px 12px;
    flex-wrap: nowrap;
    position: sticky;
    top: 0;
    z-index: 40;
  }

  header .logo {
    flex: 1;
    min-width: 0;
    gap: 8px;
  }

  header .header-brand-logo {
    height: 34px;
    max-width: 104px;
    padding: 3px 6px;
  }

  header .header-brand-text {
    font-size: 0.95rem;
    font-weight: 700;
  }

  header .header-nav {
    width: auto;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 2px;
    padding-top: 0;
    justify-content: flex-end;
  }

  header .header-nav .nav-desk-only {
    display: none;
  }

  header .header-nav a {
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
    padding: 0 10px;
  }

  .header-user-name,
  .header-signout-label,
  .theme-toggle-label {
    display: none;
  }

  .theme-toggle {
    min-width: 40px;
    height: 40px;
    padding: 0;
  }

  .role-pill {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .container {
    display: block;
  }

  .menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    padding-top: 18px;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.28);
  }

  body.nav-open .menu {
    transform: translateX(0);
  }

  .content-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    padding: 16px 14px 32px !important;
  }

  .page-title {
    font-size: 1.35rem;
    line-height: 1.25;
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .dash-card {
    padding: 14px 12px;
  }

  .dash-value {
    font-size: 1.35rem;
  }

  .dash-android-card {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
  }

  .dashboard-actions {
    width: 100%;
  }

  .dash-action-btn,
  .dash-quick-link {
    width: 100%;
    justify-content: center;
  }

  .dash-quick-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .page-menu {
    flex-wrap: wrap;
    gap: 6px;
  }

  .page-menu li {
    flex: 1 1 auto;
  }

  .incoming-toolbar,
  .incoming-actions-bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .incoming-toolbar > *,
  .incoming-actions-bar > * {
    width: 100%;
    min-width: 0;
  }

  .conv-layout {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: auto;
  }

  .conv-list {
    max-height: 38vh;
  }

  .conv-thread {
    min-height: 52vh;
  }

  .login-form {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: min(440px, calc(100vw - 28px));
    margin: 6vh auto 28px;
    padding: 22px 18px;
  }

  .footer {
    flex-direction: column;
    padding: 18px 14px 28px;
  }

  .footer .reseller-name {
    font-size: 1rem;
  }

  .footer .reseller-address {
    font-size: 0.84rem;
  }
}

@media (max-width: 560px) {
  header .header-brand-text {
    display: none;
  }

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

  .dash-label {
    font-size: 0.7rem;
  }

  .sms-cfg-grid {
    grid-template-columns: 1fr !important;
  }

  .row-actions {
    flex-direction: column;
  }

  .row-actions form,
  .row-actions button,
  .row-actions .submit-button {
    width: 100%;
  }
}

/* Safe areas for notched phones */
@supports (padding: max(0px)) {
  @media (max-width: 900px) {
    header.app-header,
    header {
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
    .content-wrapper {
      padding-bottom: max(32px, env(safe-area-inset-bottom)) !important;
    }
    .menu {
      padding-left: max(12px, env(safe-area-inset-left));
    }
  }
}

/* Landing phone polish helpers when corporate.css coexists */
body.landing .land-top {
  width: min(1080px, calc(100vw - 28px));
}
body.landing .land-cta .btn {
  min-height: 48px;
}
@media (max-width: 560px) {
  body.landing .land-hero h1 {
    font-size: clamp(2rem, 9vw, 2.6rem);
  }
  body.landing .land-features {
    grid-template-columns: 1fr;
  }
  body.landing .land-nav a:not(.land-nav-cta):not(.theme-toggle) {
    display: none;
  }
}
