@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');

/* Declare Cascade Layers */
@layer base, elements, components, layouts, utilities;

@layer base {
  :root {
    /* Harmony Palette - Solid Hex Colors */
    --primary: #7BA2E1;
    --primary-hover: #1e293b;
    --primary-light: #CCD5DD;
    --accent: #507554;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Light Theme Base Tokens (Default Premium Light-Glassmorphism) */
    --bg-gradient: #f1f5f9;
    --panel-bg: rgba(255, 255, 255, 0.65);
    --panel-border: rgba(77, 107, 179, 0.12);

    --text-main: #1e293b;
    --text-muted: #475569;
    --text-dark: #64748b;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --transition-smooth: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
  }

  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Roboto Flex', sans-serif;
    -webkit-font-smoothing: antialiased;
  }
}

@layer elements {
  body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* Custom Scrollbars */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: #e6eaf3;
  }

  ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 50px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
  }
}

@layer layouts {
  .app-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 40px 20px;
  }

  /* Product Dashboard Grid */
  .product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    animation: fadeInUp 0.8s ease;
  }

  /* Premium Page Layout (Split Calculator + Wizard view) */
  .page-container {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 40px;
    margin-top: 40px;
    animation: fadeInUp 0.6s ease;
  }

  .back-btn-container {
    margin-bottom: 24px;
  }

  .form-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-md);
    padding: 40px;
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  @media (max-width: 1120px) {
    .page-container {
      grid-template-columns: 1fr;
    }
  }
}

@layer components {

  /* Premium Header Section */
  header {
    text-align: center;
    align-items: center;
    display: flex;
    flex-direction: column;
    margin-bottom: 50px;
    position: relative;
  }

  header .brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    margin-left: auto;
    margin-right: auto;
    gap: 12px;
    margin-bottom: 16px;
    animation: fadeInDown 0.6s ease;
  }

  header .brand-logo img {
    height: 48px;
    filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.15));
  }

  header h1 {
    font-size: 2.8rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--primary);
    margin-bottom: 8px;
    text-align: center;
    animation: fadeIn 0.8s ease;
  }

  header p {
    font-size: 1.15rem;
    color: var(--text-muted);
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    animation: fadeIn 1s ease;
  }

  /* Filter and Search Layout Row */
  .filter-search-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    margin-bottom: 40px;
    width: 100%;
  }

  /* Category Filter Tabs */
  .filter-tabs {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
    justify-content: center;
    gap: 12px;
    margin-bottom: 40px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
  }

  .filter-tabs::-webkit-scrollbar {
    display: none;
    /* Safari and Chrome */
  }

  .filter-tab {
    padding: 10px 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  @media screen and (max-width: 991px) {
    .filter-search-row {
      flex-direction: column;
      align-items: flex-start;
      gap: 20px;
    }

    .filter-tabs {
      width: 100%;
      flex-direction: column;
    }
  }

  /* Glassmorphic Product Cards */
  .product-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-md);
    padding: 30px 24px;
    text-align: left;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    height: 380px;
  }

  .product-icon {
    margin: 20px 0px 0px 0px;
    align-self: flex-start;
  }

  .product-icon img {
    width: 160px;
    object-fit: contain;
  }

  .product-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-main);
    margin: 5px 0px 10px 0px;
    letter-spacing: -0.01em;
  }

  .product-desc {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
    flex-grow: 1;
  }

  .product-badge {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 5px;
    letter-spacing: 0.05em;
  }

  /* Premium CTA Buttons */
  .btn-primary {
    padding: 10px 20px;
    font-size: 1.0rem;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(77, 107, 179, 0.4);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(77, 107, 179, 0.1);
    position: relative;
    overflow: hidden;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s ease-out;
  }

  .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 50px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    justify-content: center;
  }

  .form-panel h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 12px;
  }

  /* Custom Interactive Dialog / Alerts (Glassmorphic) */
  .kshema-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .kshema-alert-box {
    background: rgba(20, 27, 45, 0.7);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-md);
    width: 90%;
    max-width: 480px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
    transform: scale(0.85);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .alert-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px auto;
    font-size: 2.2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  }

  .alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
  }

  .alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
  }

  .alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
  }

  .alert-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
  }

  .alert-message {
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.98rem;
    margin-bottom: 30px;
  }

  /* Coming Soon Styling */
  .coming-soon-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-md);
    padding: 50px 40px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--panel-shadow);
    animation: fadeInUp 0.6s ease;
  }

  .coming-soon-icon {
    font-size: 3.5rem;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
  }

  .coming-soon-card h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 15px;
    color: var(--text-main);
  }

  .coming-soon-card p {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 25px;
  }
}

@layer utilities {

  .filter-tab.active,
  .filter-tab:hover {
    background: rgba(77, 107, 179);
    color: #fff;
  }

  .product-card:hover {
    border-color: rgba(77, 107, 179, 0.65);
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(77, 107, 179, 0.08);
  }

  /* Category Badge Colors */
  .badge-crop {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
  }

  .badge-health {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
  }

  .badge-motor {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.3);
  }

  .badge-pa {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
  }

  .btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(77, 107, 179, 0.25);
  }

  .btn-primary:active::after {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 0;
    transition: 0s;
  }

  .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }

  .kshema-alert-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .kshema-alert-overlay.visible .kshema-alert-box {
    transform: scale(1);
  }

  /* Style the modal loader container */
  .calculator-loader.modal-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 9999;
  }

  /* Style the loader animation */
  .calculator-loader .loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 8px solid #f3f3f3;
    border-top: 8px solid #3498db;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 2s linear infinite;
  }

  .loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);

    display: none;

    justify-content: center;
    align-items: center;

    z-index: 99999;
  }

  .loader-gif {
    width: 220px;
    height: auto;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(30px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes fadeInDown {
    from {
      opacity: 0;
      transform: translateY(-30px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes pulse {

    0%,
    100% {
      transform: scale(1);
    }

    50% {
      transform: scale(1.08);
    }
  }
}

/* Premium Footer styles */
.footer {
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 40px 20px 20px 20px;
  margin-top: 60px;
  width: 100%;
}

.footer-content {
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 2fr;
  gap: 40px;
  padding-bottom: 30px;
  border-bottom: 1px solid rgba(77, 107, 179, 0.1);
}

.footer-brand .footer-logo {
  height: 40px;
  margin-bottom: 16px;
}

.footer-brand p {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer-links h4,
.footer-info h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
}

.footer-links ul,
.footer-info ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links ul li,
.footer-info ul li {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.footer-links ul li a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.footer-links ul li a:hover {
  color: var(--primary);
}

.footer-bottom {
  max-width: 1200px;
  margin: 20px auto 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

/* Breadcrumb Navigation styles */
.breadcrumb {
  margin: 20px 0 30px 0;
  padding: 10px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  display: inline-block;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.95rem;
}

.breadcrumb li {
  display: flex;
  align-items: center;
  color: var(--text-muted);
}

.breadcrumb li:not(:last-child)::after {
  content: "/";
  margin: 0 10px;
  color: var(--text-muted);
}

.breadcrumb li a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb li a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.breadcrumb li.active {
  color: var(--text-main);
  font-weight: 600;
}