/**
 * iMart Portal — Desk Pro UI
 * Brand palette preserved: navy #0B2C5F · red #E31C23 · surfaces from style.css
 * Corporate depth, soft 3D cards, tasteful motion.
 */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap');

:root,
html[data-theme="dark"] {
  --desk-display: 'Manrope', 'IBM Plex Sans', system-ui, sans-serif;
  --desk-depth-1: 0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 10px 30px rgba(0, 0, 0, 0.28),
    0 2px 6px rgba(0, 0, 0, 0.2);
  --desk-depth-2: 0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 18px 50px rgba(0, 0, 0, 0.35),
    0 6px 16px rgba(227, 28, 35, 0.12);
  --desk-depth-hover: 0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 28px 60px rgba(0, 0, 0, 0.4),
    0 10px 24px rgba(227, 28, 35, 0.18);
  --desk-bevel: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
  --desk-shine: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.08) 48%, transparent 62%);
  --accent-glow: 0 0 0 1px rgba(227, 28, 35, 0.35), 0 8px 28px rgba(227, 28, 35, 0.25);
  --navy-glow: 0 8px 28px rgba(11, 44, 95, 0.45);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 16px;
}

html[data-theme="light"] {
  --desk-depth-1: 0 1px 0 #fff inset,
    0 10px 28px rgba(11, 44, 95, 0.08),
    0 2px 6px rgba(11, 44, 95, 0.05);
  --desk-depth-2: 0 1px 0 #fff inset,
    0 18px 44px rgba(11, 44, 95, 0.12),
    0 6px 16px rgba(227, 28, 35, 0.08);
  --desk-depth-hover: 0 1px 0 #fff inset,
    0 26px 56px rgba(11, 44, 95, 0.16),
    0 10px 24px rgba(227, 28, 35, 0.12);
  --desk-bevel: linear-gradient(145deg, #ffffff, #f4f7fb);
  --desk-shine: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.7) 48%, transparent 62%);
}

/* ——— Ambient stage ——— */
body:not(.landing) {
  perspective: 1200px;
}

body:not(.landing)::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 50% 40% at 15% 10%, rgba(227, 28, 35, 0.14), transparent 55%),
    radial-gradient(ellipse 45% 35% at 90% 5%, rgba(11, 44, 95, 0.55), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(227, 28, 35, 0.06), transparent 40%);
  animation: deskAmbient 18s ease-in-out infinite alternate;
}

html[data-theme="light"] body:not(.landing)::before {
  background:
    radial-gradient(ellipse 50% 40% at 15% 10%, rgba(227, 28, 35, 0.07), transparent 55%),
    radial-gradient(ellipse 45% 35% at 90% 5%, rgba(11, 44, 95, 0.08), transparent 50%);
}

@keyframes deskAmbient {
  from { opacity: 0.85; transform: scale(1); }
  to { opacity: 1; transform: scale(1.04); }
}

.container,
header.app-header,
.footer {
  position: relative;
  z-index: 1;
}

/* ——— Typography ——— */
.page-title,
.form-title,
.dashboard-section-title,
.land-hero h1 {
  font-family: var(--desk-display);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-title {
  font-size: clamp(1.45rem, 2.6vw, 1.9rem);
  margin-bottom: 6px;
  background: linear-gradient(105deg, var(--text) 40%, rgba(227, 28, 35, 0.92) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

html[data-theme="light"] .page-title {
  background: linear-gradient(105deg, #0B2C5F 30%, #E31C23 160%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.page-intro,
.dashboard-welcome {
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 46rem;
}

/* ——— Header ——— */
header.app-header {
  min-height: 68px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}

header .header-brand-logo {
  height: 44px;
  border-radius: 12px;
  box-shadow: var(--desk-depth-1);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}

header .header-brand-link:hover .header-brand-logo {
  transform: translateY(-2px) rotateX(8deg);
  box-shadow: var(--desk-depth-2);
}

header .header-brand-text {
  font-family: var(--desk-display);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.role-pill {
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: var(--desk-depth-1);
  animation: pillPulse 3.2s ease-in-out infinite;
}

@keyframes pillPulse {
  0%, 100% { transform: translateZ(0); }
  50% { transform: translateY(-1px); }
}

header .header-nav a {
  border-radius: 12px;
  transition: transform 0.25s var(--ease-out), background 0.2s ease, box-shadow 0.25s ease;
}

header .header-nav a:hover {
  transform: translateY(-1px);
  box-shadow: var(--desk-depth-1);
}

.theme-toggle {
  border-radius: 12px !important;
  border: 1px solid var(--line);
  background: var(--theme-toggle-bg);
  box-shadow: var(--desk-depth-1);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px) scale(1.03);
}

/* ——— Sidebar ——— */
.menu {
  width: 260px;
  min-width: 240px;
  padding: 16px 14px 32px;
  border-right: 1px solid var(--line);
  background: var(--menu-bg);
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.12);
}

.reseller-logo {
  margin: 4px 6px 18px;
  padding: 12px;
  border-radius: 16px;
  background: var(--desk-bevel);
  border: 1px solid var(--line);
  box-shadow: var(--desk-depth-1);
  text-align: center;
  transform-style: preserve-3d;
  transition: transform 0.4s var(--ease-out);
}

.reseller-logo:hover {
  transform: translateY(-3px) rotateX(4deg);
}

.reseller-logo img {
  max-width: 148px;
  height: auto;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
}

.nav-section-label {
  display: block;
  margin: 16px 10px 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.85;
}

.menu ul li.nav-item a {
  min-height: 46px;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 600;
  transition: transform 0.28s var(--ease-out), background 0.2s ease, box-shadow 0.28s ease, color 0.2s ease;
}

.menu ul li.nav-item a:hover {
  transform: translateX(4px);
  box-shadow: var(--desk-depth-1);
}

.menu ul li.nav-item.is-active {
  background: transparent !important;
  border-color: transparent !important;
}

.menu ul li.nav-item.is-active a {
  background: linear-gradient(135deg, rgba(227, 28, 35, 0.95), rgba(196, 30, 58, 0.9));
  color: #fff !important;
  box-shadow: var(--accent-glow);
  transform: translateX(2px) translateZ(12px);
}

.menu ul li.nav-item.is-active i {
  color: #fff !important;
}

html[data-theme="light"] .menu ul li.nav-item.is-active a {
  background: linear-gradient(135deg, #E31C23, #C41E3A);
}

.menu ul li.nav-item a div {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-soft);
  margin-right: 10px;
}

.menu ul li.nav-item.is-active a div {
  background: rgba(255, 255, 255, 0.18);
}

/* ——— Content shell ——— */
.content-wrapper {
  padding: 28px 32px 56px;
  animation: deskRise 0.55s var(--ease-out) both;
}

@keyframes deskRise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.desk-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding: 22px 24px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    var(--desk-shine),
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  box-shadow: var(--desk-depth-2);
  transform: perspective(900px) rotateX(1.5deg);
  transform-origin: top center;
}

html[data-theme="light"] .desk-hero {
  background:
    var(--desk-shine),
    linear-gradient(145deg, #ffffff, #f4f7fb);
}

.desk-hero-copy {
  min-width: 0;
  flex: 1;
}

.desk-hero-copy .page-title {
  margin: 0 0 6px;
}

.desk-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.desk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--desk-depth-1);
}

.desk-chip--live {
  color: var(--success);
}

.desk-chip--live .status-dot {
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.18);
  animation: livePulse 1.8s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

/* ——— KPI cards (3D) ——— */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  perspective: 1000px;
}

.dash-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px !important;
  padding: 20px 18px !important;
  border: 1px solid var(--line) !important;
  background:
    var(--desk-shine),
    linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)) !important;
  box-shadow: var(--desk-depth-1) !important;
  transform-style: preserve-3d;
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), border-color 0.25s ease !important;
  animation: cardIn 0.6s var(--ease-out) both;
}

.dash-card:nth-child(1) { animation-delay: 0.05s; }
.dash-card:nth-child(2) { animation-delay: 0.12s; }
.dash-card:nth-child(3) { animation-delay: 0.18s; }
.dash-card:nth-child(4) { animation-delay: 0.24s; }
.dash-card:nth-child(5) { animation-delay: 0.3s; }
.dash-card:nth-child(6) { animation-delay: 0.36s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) rotateX(8deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0); }
}

.dash-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, transparent 40%, rgba(255, 255, 255, 0.12) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.7s var(--ease-out);
  pointer-events: none;
}

.dash-card:hover {
  transform: translateY(-8px) rotateX(4deg) rotateY(-2deg) !important;
  box-shadow: var(--desk-depth-hover) !important;
  border-color: rgba(227, 28, 35, 0.45) !important;
}

.dash-card:hover::after {
  transform: translateX(120%);
}

.dash-icon {
  width: 46px !important;
  height: 46px !important;
  border-radius: 14px !important;
  background: linear-gradient(145deg, rgba(227, 28, 35, 0.28), rgba(11, 44, 95, 0.35)) !important;
  box-shadow: var(--desk-depth-1);
  transform: translateZ(20px);
}

.dash-value {
  font-family: var(--desk-display);
  font-size: 1.85rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.03em;
}

/* ——— Panels / forms / tables ——— */
.dash-android-card,
.incoming-card,
.page-form,
.sender-block,
.env-banner,
.conv-panel,
.table-scroll,
.login-form {
  border-radius: 18px !important;
  border: 1px solid var(--line);
  box-shadow: var(--desk-depth-1);
  background:
    var(--desk-shine),
    linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}

html[data-theme="light"] .dash-android-card,
html[data-theme="light"] .incoming-card,
html[data-theme="light"] .page-form,
html[data-theme="light"] .sender-block,
html[data-theme="light"] .login-form,
html[data-theme="light"] .table-scroll {
  background:
    var(--desk-shine),
    linear-gradient(160deg, #ffffff, #f7f9fc);
}

.dash-android-card {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  margin-bottom: 22px;
  transform: perspective(900px) rotateX(0.8deg);
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s ease;
}

.dash-android-card:hover {
  transform: perspective(900px) translateY(-4px) rotateX(1.5deg);
  box-shadow: var(--desk-depth-2);
}

.dash-android-card h3 {
  font-family: var(--desk-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.dash-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.dash-quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 700;
  box-shadow: var(--desk-depth-1);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s ease, border-color 0.2s ease;
}

.dash-quick-link i {
  color: var(--accent);
  width: 28px;
  text-align: center;
}

.dash-quick-link:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--desk-depth-2);
  border-color: rgba(227, 28, 35, 0.4);
}

.submit-button,
.send-button,
.dash-action-btn {
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 12px !important;
  background: linear-gradient(145deg, #E31C23, #C41E3A) !important;
  box-shadow: var(--accent-glow) !important;
  transition: transform 0.28s var(--ease-out), box-shadow 0.28s ease !important;
}

.submit-button:hover,
.send-button:hover,
.dash-action-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 32px rgba(227, 28, 35, 0.4) !important;
}

.dash-action-btn--neutral {
  background: rgba(255, 255, 255, 0.08) !important;
  box-shadow: var(--desk-depth-1) !important;
}

html[data-theme="light"] .dash-action-btn--neutral {
  background: #EEF2F7 !important;
  color: #0B2C5F !important;
}

.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 {
  border-radius: 12px !important;
  transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: rgba(227, 28, 35, 0.55) !important;
  box-shadow: 0 0 0 4px rgba(227, 28, 35, 0.15);
  transform: translateY(-1px);
}

table thead th {
  font-family: var(--desk-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.72rem !important;
}

.conv-item {
  border-radius: 14px;
  transition: transform 0.25s var(--ease-out), background 0.2s ease, box-shadow 0.25s ease;
}

.conv-item:hover,
.conv-item.is-active {
  transform: translateX(4px);
  box-shadow: var(--desk-depth-1);
}

.message-success,
.message-failed {
  border-radius: 14px;
  box-shadow: var(--desk-depth-1);
  animation: deskRise 0.4s var(--ease-out) both;
}

/* ——— Login stage ——— */
body.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow-x: hidden;
}

body.login-page::before {
  content: '';
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(circle at 20% 20%, rgba(227, 28, 35, 0.22), transparent 40%),
    radial-gradient(circle at 80% 10%, rgba(11, 44, 95, 0.7), transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(227, 28, 35, 0.12), transparent 40%);
  animation: deskAmbient 14s ease-in-out infinite alternate;
  z-index: 0;
}

.login-form {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  width: min(420px, 94vw) !important;
  padding: 32px 28px 26px !important;
  z-index: 2;
  animation: loginFloat 0.7s var(--ease-out) both;
  transform-style: preserve-3d;
}

@keyframes loginFloat {
  from { opacity: 0; transform: translateY(24px) rotateX(8deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0); }
}

.login-form:hover {
  box-shadow: var(--desk-depth-hover) !important;
}

.login-brand-logo {
  box-shadow: var(--desk-depth-1);
  transition: transform 0.4s var(--ease-out);
}

.login-form:hover .login-brand-logo {
  transform: translateY(-4px) rotateX(6deg);
}

.login-shell {
  position: relative;
  z-index: 2;
  width: min(980px, 94vw);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  align-items: center;
}

.login-visual {
  padding: 28px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    var(--desk-shine),
    linear-gradient(160deg, rgba(11, 44, 95, 0.55), rgba(7, 24, 41, 0.35));
  box-shadow: var(--desk-depth-2);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transform: perspective(1000px) rotateY(4deg);
  animation: cardIn 0.8s var(--ease-out) both;
}

html[data-theme="light"] .login-visual {
  background:
    var(--desk-shine),
    linear-gradient(160deg, #0B2C5F, #123a73);
  color: #fff;
}

.login-visual h1 {
  font-family: var(--desk-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  color: #fff;
}

.login-visual p {
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.55;
  margin: 0 0 18px;
  max-width: 28rem;
}

.login-visual-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-visual-stats span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-visual {
    min-height: auto;
    transform: none;
    order: -1;
  }
}

/* ——— Footer ——— */
.footer {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
}

/* ——— Landing upgrades ——— */
body.landing .land-hero {
  transform: perspective(1200px) rotateX(1deg);
}

body.landing .land-card,
body.landing .feat {
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s ease;
  box-shadow: var(--desk-depth-1);
}

body.landing .land-card:hover,
body.landing .feat:hover {
  transform: translateY(-8px) rotateX(3deg);
  box-shadow: var(--desk-depth-hover);
}

/* ——— Reduced motion ——— */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  body:not(.landing)::before {
    display: none;
  }
}

@media (max-width: 900px) {
  .desk-hero {
    transform: none;
    padding: 18px;
  }
  .menu {
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.35);
  }
  .content-wrapper {
    padding: 18px 14px 40px;
  }
}

/* ——— Fixed corporate shell: header + sidebar stay; content scrolls ——— */
html {
  height: 100%;
}
body:not(.landing) {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body:not(.landing) > header.app-header {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 50;
}
body:not(.landing) > .container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
  margin: 0;
  width: 100%;
  max-width: none;
}
body:not(.landing) > .container > .menu {
  flex: 0 0 260px;
  width: 260px;
  min-height: 0;
  height: auto;
  align-self: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  top: auto;
  -webkit-overflow-scrolling: touch;
}
body:not(.landing) > .container > .content-wrapper {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
body:not(.landing) > .footer {
  flex: 0 0 auto;
}
@media (max-width: 900px) {
  body:not(.landing) {
    overflow: auto;
    height: auto;
    min-height: 100%;
    display: block;
  }
  body:not(.landing) > .container {
    display: block;
    overflow: visible;
    min-height: 0;
  }
  body:not(.landing) > .container > .content-wrapper {
    overflow: visible;
    width: 100%;
  }
}
