/* --- Base Styles & Variables --- */
:root {
  --primary-bg: #1a1a2e;
  --secondary-bg: #16213e;
  --tertiary-bg: #0f3460;
  --accent-color: #537895;
  --highlight-color: #e94560;
  --text-primary: #ffffff;
  --text-secondary: #a9a9a9;
  --border-radius: 8px;
  --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  /* Neon & glow palette */
  --neon-cyan: #00eaff;
  --neon-pink: #ff4ecd;
  --neon-purple: #8a2be2;
  --glass-bg: rgba(22, 33, 62, 0.55);
  --glass-border: rgba(255, 255, 255, 0.12);
}

/* Light theme overrides */
[data-theme="light"] {
  --primary-bg: #f7f7fb;
  --secondary-bg: #ffffff;
  --tertiary-bg: #e5e7eb; /* borders */
  --text-primary: #111827; /* near black */
  --text-secondary: #4b5563; /* gray-600 */
  --glass-bg: rgba(255,255,255,0.92);
  --glass-border: rgba(0,0,0,0.08);
}

[data-theme="light"] body::before {
  /* Remove heavy neon background in light mode for a clean white UI */
  display: none;
}

[data-theme="light"] .main-header {
  background: rgba(255,255,255,0.85);
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

[data-theme="light"] .service-card,
[data-theme="light"] .token-section,
[data-theme="light"] .services-section {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}

[data-theme="light"] .container {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08), 0 0 0 1px var(--glass-border);
}

/* Inputs in light theme */
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"] {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid #d1d5db;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02);
}

[data-theme="light"] .side-menu { background-color: var(--secondary-bg); }
[data-theme="light"] .header-title { color: var(--text-primary); text-shadow: none; }
[data-theme="light"] .profile-icon svg { stroke: #6b7280; }

/* Password field wrapper to place eye icon perfectly centered */
.password-wrapper {
  position: relative;
  display: inline-block; /* shrink-wrap to input height */
  width: 100%;
  overflow: hidden; /* ensure any stray pseudo-elements are clipped */
  border-radius: var(--border-radius);
  isolation: isolate; /* confine descendant effects to this stacking context */
}

.password-wrapper input[type="password"],
.password-wrapper input[type="text"] {
  padding-right: 48px; /* space tailored to 20-24px icon */
}

/* Ensure the input participates in the same grid cell as the toggle */
.password-wrapper > input[type="password"],
.password-wrapper > input[type="text"] {
  display: block;
  width: 100%;
  position: relative;
  z-index: 0;
}

.password-wrapper .toggle-password {
  all: unset; /* hard reset to avoid inherited button styles */
  position: absolute;
  top: 0;
  bottom: 0; /* stretch to input height */
  right: 10px; /* pull slightly inward */
  transform: none;
  background: transparent;
  background-color: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  outline: none;
  color: var(--text-secondary);
  display: flex; /* center icon vertically */
  align-items: center;
  justify-content: center;
  width: 36px; /* tap target, within input */
  height: 100%;
  padding: 0;
  cursor: pointer;
  z-index: 2;
}

.password-wrapper .toggle-password svg { width: 18px; height: 18px; stroke: currentColor; display:block; }

/* Remove hover/active visual effects on the eye icon */
.password-wrapper .toggle-password:hover,
.password-wrapper .toggle-password:active {
  background: transparent !important;
  box-shadow: none !important;
  filter: none !important;
  transform: none !important;
  color: var(--text-secondary) !important;
}
.password-wrapper .toggle-password:hover svg,
.password-wrapper .toggle-password:active svg {
  stroke: currentColor;
}

/* Also disable any global button sheen using pseudo-elements */
.password-wrapper .toggle-password::before,
.password-wrapper .toggle-password::after,
.password-wrapper .toggle-password:hover::before,
.password-wrapper .toggle-password:hover::after,
.password-wrapper .toggle-password:active::before,
.password-wrapper .toggle-password:active::after,
.password-wrapper .toggle-password:focus::before,
.password-wrapper .toggle-password:focus::after {
  content: none !important;
  display: none !important;
  background: none !important;
  box-shadow: none !important;
  border: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

/* Prevent any transitions/animations on hover for the icon button */
.password-wrapper .toggle-password { 
  transition: none !important; 
  background-image: none !important;
  animation: none !important;
  contain: paint; /* prevent drawing outside its box */
  clip-path: inset(0); /* hard clip visual overflow */
}

/* Also force no bg-image/animation on hover/active just in case */
.password-wrapper .toggle-password:hover,
.password-wrapper .toggle-password:active,
.password-wrapper .toggle-password:focus {
  background-image: none !important;
  animation: none !important;
}

.toggle-password:focus { outline: none; }
.toggle-password:focus-visible { outline: 2px solid var(--neon-cyan); outline-offset: 2px; border-radius: 4px; }

/* Improve auth container visibility on small screens */
@media (max-width: 480px) {
  body.auth-page { align-items: flex-start; }
  .container { margin: 12px; padding: 18px; }
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--primary-bg);
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

/* Ensure media never overflows on small screens */
img,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

/* Animated gradient backdrop */
body::before {
  content: '';
  position: fixed;
  inset: -20% -20% -20% -20%;
  background: radial-gradient(35% 35% at 20% 20%, rgba(233,69,96,0.25) 0%, rgba(233,69,96,0) 100%),
              radial-gradient(40% 40% at 80% 30%, rgba(0,234,255,0.18) 0%, rgba(0,234,255,0) 100%),
              radial-gradient(45% 45% at 50% 80%, rgba(138,43,226,0.18) 0%, rgba(138,43,226,0) 100%);
  filter: blur(40px) saturate(1.1);
  animation: floatHue 18s ease-in-out infinite alternate;
  z-index: 0;
  pointer-events: none; /* never block clicks */
}

/* If the system requests reduced motion, disable the animated backdrop globally */
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none !important; }
}

/* Turn off animated background glow on dashboard to avoid light streaks over cards */
.dashboard-page::before,
body.dashboard-page::before,
html.dashboard-page::before {
  display: none !important;
  content: none !important;
  background: none !important;
  animation: none !important;
  filter: none !important;
  pointer-events: none !important;
}

/* Also disable button sheen animation only on the dashboard page */
.dashboard-page .btn::after,
.dashboard-page button::after {
  content: none !important;
  animation: none !important;
}

/* Remove blur filters on dashboard to avoid shimmer/flicker on some GPUs */
.dashboard-page .main-header,
.dashboard-page .container {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Ensure a static backdrop for the whole dashboard page */
body.dashboard-page {
  background: var(--primary-bg) !important;
}

/* Minimize hover-induced flicker on dashboard cards */
.dashboard-page .service-card { transition: none !important; }
.dashboard-page .service-card:hover {
  transform: none !important;
  box-shadow: var(--box-shadow) !important; /* keep base shadow */
}

@keyframes floatHue {
  0%   { transform: translate3d(0,0,0) scale(1); filter: hue-rotate(0deg) blur(40px); }
  50%  { transform: translate3d(-2%,2%,0) scale(1.03); filter: hue-rotate(20deg) blur(44px); }
  100% { transform: translate3d(2%,-1%,0) scale(1.05); filter: hue-rotate(-15deg) blur(46px); }
}

/* --- Landing Page Specific --- */
.landing-header {
    background: var(--secondary-bg);
    padding: 0;
    border-bottom: 1px solid var(--tertiary-bg);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 100px;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo {
    font-size: 1.8rem !important;
    margin: 0 !important;
    cursor: pointer;
}

.landing-header nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-buttons {
    display: flex;
    gap: 1rem;
}

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 20px;
    text-align: center;
}

.hero h2 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem auto;
}

/* --- Centering for Auth pages --- */
body.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- Auth Brand Header --- */
.auth-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 10px auto;
  text-decoration: none;
}
.auth-brand img {
  height: 50px;
  width: auto;
  display: block;
}
.auth-brand .brand-name {
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-shadow: 0 0 10px rgba(0,234,255,0.16);
}

@media (max-width: 480px) {
  .auth-brand {
    gap: 8px;
    margin-bottom: 8px;
  }
  .auth-brand img { height: 30px; }
  .auth-brand .brand-name { font-size: 1rem; }
}

/* --- Main Container & Card --- */
.container {
  max-width: 480px;
  width: 100%;
  margin: 20px;
  padding: 44px;
  background: var(--glass-bg);
  border-radius: 16px;
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow:
    0 10px 30px rgba(0,0,0,0.35),
    0 0 0 1px var(--glass-border),
    0 0 14px rgba(233,69,96,0.08);
  text-align: center;
  border: 1px solid var(--glass-border);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  z-index: 1;
}

.container:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 45px rgba(0,0,0,0.45), 0 0 24px rgba(0,234,255,0.12);
}

h1, h2, h3 {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 600;
}

h2 {
    font-size: 2rem;
    font-weight: 500;
}

/* --- Forms & Inputs --- */
form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem; /* Increased gap for better spacing */
  text-align: left;
}

form div {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(26,26,46,0.9), rgba(26,26,46,0.7));
  color: var(--text-primary);
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  box-sizing: border-box; /* Ensures padding doesn't affect width */
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: rgba(0,234,255,0.6);
  box-shadow: 0 0 0 3px rgba(0, 234, 255, 0.22), 0 0 25px rgba(0,234,255,0.12);
}

/* --- Buttons --- */
.btn, button {
  background: linear-gradient(135deg, var(--highlight-color), var(--neon-purple));
  color: var(--text-primary);
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 1rem;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(233,69,96,0.18), 0 0 0 1px rgba(255,255,255,0.06);
}

.btn:hover, button:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 14px 30px rgba(233,69,96,0.28), 0 0 18px rgba(0,234,255,0.18);
}

/* Button shine animation */
.btn::after, button::after {
  content: '';
  position: absolute;
  top: -100%;
  left: -30%;
  width: 60%;
  height: 300%;
  background: linear-gradient(120deg, rgba(255,255,255,0.2), rgba(255,255,255,0));
  transform: rotate(25deg);
  transition: opacity 0.2s ease;
  opacity: 0;
}

.btn:hover::after, button:hover::after {
  opacity: 1;
  animation: swipe 0.9s ease forwards;
}

@keyframes swipe {
  from { transform: translateX(-80%) rotate(25deg); }
  to   { transform: translateX(220%) rotate(25deg); }
}

/* --- Message & Status Text --- */
#dashboardMsg,
#signupMsg,
#loginMsg {
  color: var(--highlight-color);
  text-align: center;
  margin-top: -1.5rem;
  min-height: 1.2em;
}

/* Password toggle icon hover */
button#toggleLoginPwd,
button#toggleSignupPwd,
button#toggleResetPwd {
  transition: transform 0.2s ease, color 0.2s ease, text-shadow 0.2s ease;
}

button#toggleLoginPwd:hover,
button#toggleSignupPwd:hover,
button#toggleResetPwd:hover {
  transform: scale(1.1);
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0,234,255,0.6);
}

/* --- Dashboard Specific --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

#userInfo p {
    margin: 0;
    font-size: 1.1rem;
}

#logoutBtn {
    background: transparent;
    border: 1px solid var(--highlight-color);
    color: var(--highlight-color);
    padding: 8px 16px;
    margin-top: 0;
}

#logoutBtn:hover {
    background: var(--highlight-color);
    color: var(--text-primary);
}

.token-section, .services-section {
  background: var(--primary-bg);
  padding: 20px;
  border-radius: var(--border-radius);
  margin-top: 2rem;
}

.token-section h3, .services-section h3 {
    margin-top: 0;
    border-bottom: 1px solid var(--tertiary-bg);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

#tokenCount {
    font-size: 3rem;
    font-weight: 700;
    color: var(--highlight-color);
}

.service {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--tertiary-bg);
}

.service:last-child {
    border-bottom: none;
}

/* --- New Dashboard Layout --- */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  transition: margin-left .5s, filter .5s;
  box-sizing: border-box;
}

.main-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 0; /* normalize spacing below header across pages */
  padding: 1rem 2rem;
  background: rgba(22,33,62,0.55);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100; /* ensure header stays above content */
  height: 72px; /* unified header height */
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  box-shadow: 0 8px 25px rgba(0,0,0,0.35);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Hide title text in headers globally as requested */
.main-header .header-title { display: none; }

/* Simple theme toggle control */
.theme-toggle-btn {
  margin-right: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--tertiary-bg);
  background: var(--secondary-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 600;
  box-shadow: none;
}
[data-theme="light"] .theme-toggle-btn {
  background: #ffffff;
  border-color: #e5e7eb;
  color: #111827;
}

/* Toggle Switch Styles (global) */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--tertiary-bg); /* neutral default for non-theme switches */
  transition: .2s;
  border-radius: 28px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 4px; top: 4px;
  background: #ffffff;
  transition: .2s;
  border-radius: 50%;
}
.slider:after {
  content: none; /* no icon by default */
  position: absolute;
  top: 50%;
  right: 10px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  transition: .2s;
  pointer-events: none;
  z-index: 0;
}
input:focus + .slider { box-shadow: 0 0 1px rgba(79, 70, 229, 0.6); }
input:checked + .slider:before { transform: translateX(22px); }

/* THEME SWITCH (sun/moon) - header and admin only */
.switch.header-theme-switch .slider,
.switch.theme-switch .slider {
  background: #0f172a; /* dark track when unchecked */
}
.switch.header-theme-switch input:checked + .slider,
.switch.theme-switch input:checked + .slider {
  background-color: #f59e0b; /* orange for light */
}
.switch.header-theme-switch .slider:after,
.switch.theme-switch .slider:after {
  content: "";
  right: 10px; /* show moon on right when dark */
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M21 12.79A9 9 0 1111.21 3a7 7 0 109.79 9.79z'/%3E%3C/svg%3E");
}
.switch.header-theme-switch input:checked + .slider:after,
.switch.theme-switch input:checked + .slider:after {
  right: auto;
  left: 10px; /* move icon to left when light */
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cline x1='12' y1='1' x2='12' y2='4'/%3E%3Cline x1='12' y1='20' x2='12' y2='23'/%3E%3Cline x1='1' y1='12' x2='4' y2='12'/%3E%3Cline x1='20' y1='12' x2='23' y2='12'/%3E%3Cline x1='4.22' y1='4.22' x2='6.34' y2='6.34'/%3E%3Cline x1='17.66' y1='17.66' x2='19.78' y2='19.78'/%3E%3Cline x1='4.22' y1='19.78' x2='6.34' y2='17.66'/%3E%3Cline x1='17.66' y1='6.34' x2='19.78' y2='4.22'/%3E%3C/svg%3E");
}

.header-logo {
  max-height: 100%; /* scale to header height */
  height: auto;
  cursor: pointer;
}

.header-title {
  font-size: 1.8rem;
  color: var(--text-primary);
  margin: 0;
  text-shadow: 0 0 12px rgba(0,234,255,0.25);
}

.profile-icon {
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.3s, transform 0.2s ease, filter 0.2s ease;
}

.profile-icon svg {
    stroke: var(--text-secondary);
    transition: stroke 0.3s;
}

.profile-icon:hover svg {
  stroke: var(--highlight-color);
}

/* --- Side Menu --- */
.menu-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 1rem 20px 0 20px;
    box-sizing: border-box;
}

.menu-buttons.logged-out {
    flex-direction: row;
    justify-content: center;
}

.menu-buttons.logged-out .btn,
.menu-buttons.logged-out .btn-secondary {
    width: auto;
    flex-grow: 1;
}

.menu-buttons .btn-menu {
    width: 100%;
}
.side-menu {
  height: 100%;
  width: 0; /* Hidden by default */
  position: fixed;
  z-index: 1000;
  top: 0;
  right: 0;
  background-color: var(--secondary-bg);
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: -5px 0px 15px rgba(0,0,0,0.2);
}

.side-menu.open {
    width: 300px;
}

.side-menu .close-btn {
  position: absolute;
  top: 15px;
  right: 25px;
  font-size: 36px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.3s;
}

.side-menu .close-btn:hover {
    color: var(--highlight-color);
}

.user-info-menu {
    text-align: center;
    margin-bottom: 2rem;
    padding: 0 20px;
}

.user-info-menu h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.4rem;
    color: var(--text-primary);
}

.user-info-menu p {
    margin: 0;
    font-weight: 400; /* Adjusted font weight */
    color: var(--text-secondary); /* Softer color for email */
    font-size: 1rem;
}

.token-info-menu {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--primary-bg);
    border-radius: var(--border-radius);
    width: 80%;
}

.token-info-menu p {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.token-info-menu h3 {
    margin: 0;
    color: var(--highlight-color);
    font-size: 1.8rem;
}

.btn-menu {
    width: 80%;
    margin-top: 1rem;
    text-align: center;
}

#buyTokensBtn {
    margin-bottom: 1rem; /* Adds space below the buy button */
}

.btn-menu.logout {
    margin-top: auto; /* Pushes to the bottom */
    margin-bottom: 2rem;
    background: transparent;
    border: 1px solid var(--highlight-color);
}

.btn-menu.logout:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

/* --- Service Grid & Cards --- */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  padding: 0 20px;
}

.service-card {
  background: var(--secondary-bg);
  border-radius: var(--border-radius);
  padding: 30px;
  box-shadow: var(--box-shadow);
  border: 1px solid var(--tertiary-bg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(233, 69, 96, 0.1);
}

.service-card h3 {
  font-size: 1.3rem; /* slightly smaller title */
  color: var(--highlight-color);
  margin-top: 0;
  margin-bottom: 5px; /* tight gap under title */
}

/* Ensure consistent header height for service/product cards */
.service-card > h3,
.service-card-header h3 {
  min-height: 0; /* remove enforced height to keep gap tight */
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.service-card p {
  color: var(--text-secondary);
  flex-grow: 1; /* Pushes button to the bottom */
  font-size: 0.9rem; /* smaller description text */
  line-height: 1.5;  /* comfortable readability at smaller size */
}

.service-card .service-card-body { /* tighter gap between title and description */
  margin-top: 5px;
}

.service-card button {
  width: 100%;
}

/* Inline "more.." control for truncated descriptions */
.service-card .product-desc {
  white-space: normal; /* allow natural wrapping */
  overflow: visible;   /* no clipping when expanded */
  margin-bottom: 0;    /* keep more/less close to text */
}
.service-card .desc-more {
  all: unset; /* remove global button styles */
  display: inline-block;
  margin-top: 3px; /* tighter gap under description */
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: none; /* no underline */
  cursor: pointer;
}
.service-card .desc-more:hover {
  /* no hover animation or color change */
  color: var(--text-secondary);
  text-decoration: none; /* keep underline off on hover */
  transition: none !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Spacing above dynamically generated products grid */
#productsGrid {
  margin-top: 24px;
}

/* Product media (image on top of card) */
.product-media {
  width: 100%;
  height: 180px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--secondary-bg);
  border: 1px solid var(--tertiary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.product-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Maintenance state for product cards on dashboard */
.service-card.maintenance {
  filter: grayscale(0.9);
  opacity: 0.6;
}
.service-card .maint-msg {
  margin-top: 10px;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700; /* Bold label */
  letter-spacing: .2px;
  background: rgba(233,69,96,0.18);
  color: #ff4d6d; /* stronger red */
  border: 1px solid rgba(233,69,96,0.45);
  box-shadow: 0 0 12px rgba(233,69,96,0.45), 0 0 22px rgba(233,69,96,0.22);
  text-shadow: 0 0 6px rgba(233,69,96,0.35);
}

/* Keep the header fully visible in maintenance; dim only body/actions */
.service-card.maintenance { filter: none; opacity: 1; }
.service-card.maintenance .service-card-body,
.service-card.maintenance .service-card-actions { filter: grayscale(0.9); opacity: 0.6; }
.service-card.maintenance .service-card-header { filter: none; opacity: 1; }

/* Header layout to place the badge above gray part */
.service-card-header {
  flex-direction: column;
  display: flex;
  align-items: left;
  justify-content: flex-start;
  gap: 10px;
}
.service-card-header .maint-msg { margin-top: 0; }

/* 3D-style icon next to maintenance label */
.service-card .maint-msg .maint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  filter: drop-shadow(0 2px 4px rgba(233,69,96,0.35));
  vertical-align: middle;
}
.service-card .maint-msg .maint-icon svg {
  stroke: #ff4d6d; /* match red */
}

/* --- Overlay --- */
.overlay {
  position: fixed;
  display: none;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 500;
  transition: opacity 0.5s;
}

.overlay.active {
    display: block;
}

/* --- Modal Styles --- */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 1001; /* Sit on top of the overlay */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.show {
  display: block;
  opacity: 1;
}

.modal-content {
  background-color: var(--secondary-bg);
  margin: 15% auto;
  padding: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 80%;
  max-width: 400px;
  text-align: center;
  position: relative;
  transform: translateY(-50px);
  transition: transform 0.3s ease;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .landing-header { height: 80px; }
  .header-container { padding: 0 16px; }
  .header-logo { max-height: 100%; height: auto; }
}

@media (max-width: 768px) {
  .main-container { padding: 2rem 16px; }
  .hero h2 { font-size: 2.2rem; }
  .hero p { font-size: 1rem; }
  .service-grid { grid-template-columns: 1fr; padding: 0 10px; }
  .container { padding: 28px; margin: 16px; }
  .side-menu.open { width: 88%; }
  .header-logo { height: 56px; max-height: 100%; }
  .landing-header { height: 70px; }
  /* Global header and content tightening for small tablets */
  .main-header { height: 64px; padding: 0.75rem 12px; }
  .main-content { padding: 12px; }
}

@media (max-width: 480px) {
  .logo { font-size: 1.4rem !important; }
  .header-title { font-size: 1.2rem; }
  .btn, button { width: 100%; }
  .container { padding: 22px; }
  .header-container { padding: 0 12px; }
  .service-card { padding: 20px; }
  .modal-content { width: 92%; }
  /* Further tighten global header and content on phones */
  .main-header { height: 56px; padding: 0.5rem 10px; }
  .header-logo { height: 44px; }
  .main-content { padding: 10px; }
}

/* Global mobile scroll fix: ensure page can scroll vertically */
@media (max-width: 768px) {
  html, body {
    height: auto !important;
    min-height: 100% !important;
    overflow-y: auto !important;
  }
  /* Prevent inner wrappers from locking viewport height */
  .wrap,
  .resp,
  .resp-sticky,
  .viewport,
  .left-scroll {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  /* But allow scrolling inside known scroll areas when needed */
  .viewport { overflow: auto !important; }
}

.modal.show .modal-content {
  transform: translateY(0);
}

.modal-content h2 {
  margin-top: 0;
  color: var(--text-primary);
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.close-modal-btn {
  color: var(--text-secondary);
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
}

.close-modal-btn:hover,
.close-modal-btn:focus {
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
}

/* --- Admin Panel Specific --- */
.admin-container {
  max-width: 960px; /* Wider container for the table */
  margin: 40px auto;
  padding: 40px;
  background: var(--secondary-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  border: 1px solid var(--tertiary-bg);
}

#users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 2rem;
}

#users-table th,
#users-table td {
  padding: 15px;
  text-align: left;
  border-bottom: 1px solid var(--tertiary-bg);
}

#users-table th {
  background-color: var(--tertiary-bg);
  color: var(--text-primary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.9rem;
}

#users-table tbody tr {
  transition: background-color 0.3s ease;
}

#users-table tbody tr:hover {
  background-color: var(--primary-bg);
}

#users-table td {
  color: var(--text-secondary);
}

#users-table td:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

.actions-cell {
    display: flex;
    gap: 10px;
}

.edit-btn,
.history-btn {
    padding: 8px 12px !important;
    font-size: 0.9rem !important;
    margin-top: 0 !important;
    background: var(--accent-color) !important;
}

.edit-btn:hover,
.history-btn:hover {
    background: var(--highlight-color) !important;
}

/* Ensure admin modals use existing styles but with slight adjustments if needed */
#edit-user-modal .modal-content,
#payment-history-modal .modal-content {
    background: var(--secondary-bg);
    max-width: 500px;
}

/* --- History Icon & Modal Styles --- */
.history-icon {
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.3s, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-icon svg {
  stroke: var(--text-secondary);
  transition: stroke 0.3s;
}

.history-icon:hover {
  background-color: var(--tertiary-bg);
}

.history-icon:hover svg {
  stroke: var(--highlight-color);
}

.history-modal .modal-content {
  max-width: 1000px;
  max-height: 85vh;
  overflow-y: auto;
}

.history-list {
  margin-top: 20px;
  overflow-x: auto;
}

/* History Table Styles */
.history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--secondary-bg);
  border-radius: 8px;
  overflow: hidden;
}

.history-table thead {
  background: var(--tertiary-bg);
}

.history-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  color: var(--highlight-color);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--primary-bg);
}

.history-table tbody tr {
  border-bottom: 1px solid var(--tertiary-bg);
  transition: background-color 0.2s ease;
}

.history-table tbody tr:hover {
  background-color: var(--tertiary-bg);
}

.history-table tbody tr:last-child {
  border-bottom: none;
}

.history-table td {
  padding: 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.history-table td:first-child {
  font-weight: 500;
}

.history-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-color);
  color: white;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  margin-right: 8px;
  margin-bottom: 4px;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.history-download-btn:hover {
  background: var(--highlight-color);
  transform: translateY(-1px);
}

.history-download-btn svg {
  stroke: white;
}

/* Responsive history table */
@media (max-width: 768px) {
  .history-modal .modal-content {
    width: 95%;
    max-height: 90vh;
  }
  
  .history-table th,
  .history-table td {
    padding: 12px 8px;
    font-size: 0.9rem;
  }
  
  .history-download-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
}

/* ===== History Page (Grid) ===== */
.history-page .wrap { margin-top: 20px; }
.history-toolbar { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.history-search { flex:1; min-width: 240px; padding:10px 12px; border-radius:8px; background: var(--secondary-bg); color: var(--text-primary); border: 1px solid var(--tertiary-bg);} 
.history-filters select, .history-filters input[type=date] { padding:8px 10px; border-radius:8px; background: var(--secondary-bg); color: var(--text-primary); border:1px solid var(--tertiary-bg);} 
.history-grid { margin-top:16px; columns: 3 320px; column-gap: 16px; }
.history-card { break-inside: avoid; background: var(--secondary-bg); border:1px solid var(--tertiary-bg); border-radius:12px; margin:0 0 16px; overflow:hidden; box-shadow: 0 6px 14px rgba(0,0,0,.25);} 
.history-card .thumb-wrap { position:relative; cursor:pointer; background:#0b0f14; }
.history-card img { width:100%; height:auto; display:block; }
.video-badge { position:absolute; left:10px; top:10px; background: rgba(0,0,0,.6); color:#fff; padding:4px 8px; border-radius:999px; font-size:12px; }
.history-card .card-body { padding:12px; }
.badges { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:6px; }
.badge { display:inline-block; font-size:11px; padding:4px 8px; border-radius:999px; background: var(--tertiary-bg); color: var(--text-secondary);} 
.badge.image { background: #22324a; color:#8fb4ff; } 
.badge.video { background: #3a2837; color:#ff89d0; }
.badge.product { background: #23322a; color:#7be497; }
.badge.deleted { background: #402626; color:#ff9b9b; }
.badge.status { background: #42361f; color:#ffd27a; }
.meta { color: var(--text-secondary); font-size: 12px; margin-bottom: 10px; }
.actions { display:flex; gap:8px; flex-wrap:wrap; }
.btn { padding:8px 12px; border-radius:8px; background: var(--accent-color); color:#fff; border:none; cursor:pointer; text-decoration:none; font-size: 13px; }
.btn:hover { background: var(--highlight-color); }
.btn-secondary { background: #2b3b52; }
.btn-danger { background: #c94141; }
.btn-link { background: transparent; color: var(--highlight-color); text-decoration: underline; }
.load-more-wrap { display:none; justify-content:center; margin-top:20px; }
.is-deleted { opacity: .6; filter: grayscale(0.3); }

/* Lightbox */
.history-modal .modal-content { max-width: 1000px; }
.lightbox-view { display:flex; justify-content:center; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: rgba(0,0,0,.8); color:#fff; padding:10px 14px; border-radius: 8px; z-index: 10000; display:flex; gap:8px; align-items:center; }

@media (max-width: 1024px) { .history-grid { columns: 2 280px; } }
@media (max-width: 640px) { .history-grid { columns: 1 100%; } }
