/* Google Fonts Local Hosting (Inter) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-400.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter-500.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/inter-600.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/inter-700.ttf') format('truetype');
}

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-primary: #ffffff;
  --bg-secondary: #f1f5f9;
  --bg-muted: #f1f5f9;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);
  --radius: 0.75rem;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header / Nav */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  font-size: 1.5rem;
  background: #e0e7ff;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  letter-spacing: -0.025em;
}

nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  background: transparent;
  border: none;
  cursor: pointer;
}

.nav-link:hover,
.nav-link:focus {
  color: var(--primary);
  background-color: #f1f5f9;
  outline: none;
}

.nav-icon {
  font-size: 1.1rem;
}

/* Dropdowns */
.nav-dropdown {
  position: relative;
}

.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-arrow {
  font-size: 0.7rem;
  opacity: 0.5;
  transition: transform 0.2s;
}

.nav-dropdown:hover .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  display: none;
  z-index: 100;
  padding: 0.5rem;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-main);
  text-decoration: none;
  border-radius: 0.5rem;
  transition: background 0.2s;
  font-size: 0.9rem;
}

.dropdown-menu a:hover {
  background-color: #f8fafc;
  color: var(--primary);
}

.menu-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border);
  margin: 0.5rem 0;
}

/* User Menu */
.user-menu {
  position: relative;
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.user-menu-btn {
  background: transparent;
  border: none;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  border-radius: 2rem;
  transition: background 0.2s;
}

.user-menu-btn:hover,
.user-menu-btn:focus {
  background-color: #f1f5f9;
  outline: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.user-dropdown {
  width: 260px;
  padding: 0;
  overflow: hidden;
}

.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: var(--text-main);
  text-decoration: none;
  transition: background-color 0.2s;
}

.user-dropdown a:hover {
  background-color: #f8fafc;
}

.user-info {
  padding: 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar-large {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name-large {
  font-weight: 700;
  color: var(--text-main);
}

.user-plan-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #e2e8f0;
  padding: 0.1rem 0.5rem;
  border-radius: 1rem;
  align-self: flex-start;
  margin-top: 0.25rem;
}

.logout-link {
  color: #ef4444 !important;
}

.logout-link:hover {
  background-color: #fef2f2 !important;
}

/* Upgrade Button */
.upgrade-btn {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  display: inline-block;
}

.upgrade-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 8px -1px rgba(99, 102, 241, 0.4);
  color: white;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  /* DESKTOP UI: Reduced from 2rem for less scrolling */
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Typography */
h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 1rem;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 400px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

input,
select {
  margin-top: 0.25rem;
  padding: 0.625rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.75em 1em;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5em;
  background: var(--bg-card);
  color: var(--text-main);
  box-sizing: border-box;
  margin-bottom: 1em;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

button {
  background-color: var(--primary);
  color: white;
  padding: 0.75rem;
  border: none;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

button:hover {
  background-color: var(--primary-hover);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

tr:last-child td {
  border-bottom: none;
}

/* Utilities */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.flash {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 500;
}

.flash.error {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.flash.success {
  background-color: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Password Eye Icon */
.toggle-password {
  font-size: 1.2rem;
  color: #888;
  user-select: none;
  transition: color 0.2s;
}

.toggle-password:hover {
  color: #333;
}

.password-box {
  position: relative;
  display: flex;
  align-items: center;
}

.password-box input[type="password"],
.password-box input[type="text"] {
  width: 100%;
  padding-right: 2.2em;
  box-sizing: border-box;
}

.password-box .toggle-password {
  position: absolute;
  right: 0.7em;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: #888;
  user-select: none;
  cursor: pointer;
  transition: color 0.2s;
}

.password-box .toggle-password:hover {
  color: #333;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Hamburger Menu Button (Hidden on Desktop) */
.hamburger-menu {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1000;
  transition: all 0.3s ease;
  outline: none;
}

.hamburger-menu:hover,
.hamburger-menu:focus {
  background: rgba(0, 0, 0, 0.05);
  outline: none;
}

.hamburger-menu span {
  width: 24px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
  display: block;
}

.hamburger-menu.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Bottom Navigation (Mobile Only) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.5rem 1rem;
  min-width: 60px;
  transition: color 0.2s;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item:hover {
  color: var(--primary);
}

.bottom-nav-icon {
  font-size: 1.5rem;
}

/* Mobile Breakpoint: Tablets and Phones */
@media (max-width: 768px) {

  /* Header Adjustments */
  header {
    padding: 0.75rem 1rem;
    flex-wrap: nowrap;
    align-items: center;
  }

  .header-brand {
    flex: 1;
  }

  .header-brand h1 {
    font-size: 1.1rem;
  }

  /* Show Hamburger Menu */
  .hamburger-menu {
    display: flex;
  }

  /* Hide Desktop Navigation - Target main nav specifically */
  nav#mainNav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 4rem 0 0 0;
    transition: right 0.3s ease;
    overflow-y: auto;
    z-index: 999;
  }

  nav#mainNav.active {
    right: 0 !important;
  }

  /* Navigation Links in Mobile Menu */
  nav#mainNav .nav-link,
  nav#mainNav .nav-dropdown {
    width: 100%;
    padding: 1rem 1.5rem;
    border-radius: 0;
    justify-content: flex-start;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
  }

  nav#mainNav .nav-link:hover {
    background: #f8fafc;
  }

  /* Dropdown Menus in Mobile */
  nav#mainNav .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    margin-top: 0;
    padding: 0;
    background: #f8fafc;
    display: none;
    /* Hidden by default */
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  nav#mainNav .dropdown-menu a {
    padding: 0.75rem 2.5rem;
    font-size: 0.9rem;
    display: block;
  }

  /* Rotate arrow when dropdown is open */
  nav#mainNav .dropdown-trigger .dropdown-arrow {
    transition: transform 0.3s ease;
  }

  nav#mainNav .nav-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
  }

  /* User Menu in Mobile Nav */
  nav#mainNav .user-menu {
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
  }

  nav#mainNav .user-menu-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    border-radius: 0;
    justify-content: flex-start;
    border-bottom: 1px solid var(--border);
  }

  nav#mainNav .user-dropdown {
    position: static;
    width: 100%;
    box-shadow: none;
    border: none;
    background: #f8fafc;
  }

  nav#mainNav .user-name {
    display: inline;
  }

  /* Show Bottom Navigation */
  .bottom-nav {
    display: block;
  }

  /* Add padding to content to account for bottom nav */
  .container {
    padding: 1rem 1rem 5rem 1rem;
  }

  /* Mobile Overlay */
  body.menu-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }

  /* Cards */
  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  /* Forms */
  form {
    max-width: 100%;
  }

  input,
  select,
  button {
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  /* Touch Targets - Minimum 44px */
  button,
  .nav-link,
  .btn-primary,
  .upgrade-btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Grid Layouts */
  .grid-2 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Tables - Horizontal Scroll */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.875rem;
  }

  th,
  td {
    padding: 0.5rem;
    white-space: nowrap;
  }

  /* Upgrade Button */
  .upgrade-btn {
    width: 100%;
    text-align: center;
    margin: 0.5rem 1.5rem;
  }
}

/* Small Phones */
@media (max-width: 480px) {
  header h1 {
    font-size: 1rem;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }

  .container {
    padding: 0.75rem 0.75rem 5rem 0.75rem;
  }

  .card {
    padding: 0.75rem;
  }

  /* Smaller Bottom Nav Icons */
  .bottom-nav-icon {
    font-size: 1.25rem;
  }

  .bottom-nav-item {
    font-size: 0.65rem;
    padding: 0.4rem 0.5rem;
    min-width: 50px;
  }

  /* Reduce font sizes */
  h2 {
    font-size: 1.1rem;
  }

  button {
    padding: 0.625rem;
    font-size: 0.875rem;
  }
}

/* Landscape Phones */
@media (max-width: 768px) and (orientation: landscape) {
  nav {
    width: 240px;
  }

  .bottom-nav {
    padding: 0.25rem 0;
  }

  .bottom-nav-item {
    padding: 0.25rem 0.75rem;
  }
}

/* Tablets in Portrait */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    padding: 1.5rem;
  }

  nav {
    gap: 0.25rem;
  }

  .nav-link {
    font-size: 0.85rem;
    padding: 0.5rem 0.6rem;
  }
}

/* Demo Mode Banner */
.demo-banner {
  background: linear-gradient(to right, #fbbf24, #f59e0b);
  color: #000;
  text-align: center;
  padding: 8px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.demo-banner span {
  font-size: 1.1rem;
}

.demo-banner strong {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 768px) {
  .demo-banner {
    font-size: 0.75rem;
    padding: 6px 15px;
  }
}

/* Demo Restricted - Functional Action Lock */
.demo-restricted-action {
  cursor: not-allowed !important;
  position: relative;
  opacity: 0.6;
  pointer-events: auto !important;
  /* Keep events to trigger the JS alert */
  transition: all 0.3s ease;
  filter: grayscale(0.5);
}

.demo-restricted-action:hover {
  transform: none !important;
  background: var(--bg-secondary) !important;
  color: var(--text-muted) !important;
}

.demo-restricted-action::after {
  content: '🔒';
  font-size: 0.8rem;
  position: absolute;
  top: -5px;
  right: -5px;
  background: white;
  border-radius: 50%;
  padding: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  z-index: 10;
}