/**
 * BusinessFlex Main Stylesheet
 *
 * Fully modular CSS Grid & Flexbox system powered by CSS Custom Properties.
 *
 * @package BusinessFlex
 * @since 1.0.0
 */

/* ==========================================================================
   1. CSS Reset & Base Variables
   ========================================================================== */

:root {
  /* Default fallbacks if dynamic tokens not yet injected */
  --businessflex-container-max: 1200px;
  --businessflex-reading-max: 760px;
  --businessflex-page-padding: 16px;
  --businessflex-font-size-base: 16px;

  --businessflex-color-primary: #1D4ED8;
  --businessflex-color-primary-hover: #1E40AF;
  --businessflex-color-secondary: #0F766E;
  --businessflex-color-accent: #B45309;
  --businessflex-color-background: #FFFFFF;
  --businessflex-color-surface-alt: #F8FAFC;
  --businessflex-color-headings: #0F172A;
  --businessflex-color-text: #334155;
  --businessflex-color-muted: #64748B;
  --businessflex-color-border: #CBD5E1;

  --businessflex-font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --businessflex-radius-sm: 4px;
  --businessflex-radius-md: 8px;
  --businessflex-radius-lg: 12px;
  --businessflex-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --businessflex-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --businessflex-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --businessflex-transition: all 0.2s ease-in-out;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--businessflex-font-system);
  font-size: var(--businessflex-font-size-base);
  line-height: 1.65;
  color: var(--businessflex-color-text);
  background-color: var(--businessflex-color-background);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   2. Typography & Core Elements
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  color: var(--businessflex-color-headings);
  font-weight: 700;
  line-height: 1.25;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

h1:first-child, h2:first-child, h3:first-child {
  margin-top: 0;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; }

p {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

a {
  color: var(--businessflex-color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: var(--businessflex-transition);
}

a:hover, a:focus {
  color: var(--businessflex-color-primary-hover);
  text-decoration-thickness: 2px;
}

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

figure {
  margin: 0 0 1.5rem 0;
}

figcaption {
  font-size: 0.875rem;
  color: var(--businessflex-color-muted);
  text-align: center;
  margin-top: 0.5rem;
}

blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--businessflex-color-primary);
  background-color: var(--businessflex-color-surface-alt);
  font-style: italic;
  border-radius: 0 var(--businessflex-radius-md) var(--businessflex-radius-md) 0;
}

/* ==========================================================================
   3. Accessibility & Utilities
   ========================================================================== */

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute !important;
  width: 1px;
  word-wrap: normal !important;
}

.screen-reader-text:focus {
  background-color: #0F172A;
  border-radius: 4px;
  box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.4);
  clip: auto !important;
  clip-path: none;
  color: #FFFFFF;
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  height: auto;
  left: 8px;
  top: 8px;
  line-height: normal;
  padding: 12px 20px;
  text-decoration: none;
  width: auto;
  z-index: 100000;
}

:focus-visible {
  outline: 2px solid var(--businessflex-color-primary);
  outline-offset: 2px;
}

/* ==========================================================================
   4. Layout & Containers
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--businessflex-container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--businessflex-page-padding);
  padding-right: var(--businessflex-page-padding);
}

.reading-container {
  width: 100%;
  max-width: var(--businessflex-reading-max);
  margin-left: auto;
  margin-right: auto;
}

.alignwide {
  width: 100%;
  max-width: var(--businessflex-container-max);
  margin-left: auto;
  margin-right: auto;
}

.alignfull {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.layout-boxed {
  background-color: #F1F5F9;
}

.layout-boxed #page {
  max-width: 1440px;
  margin: 0 auto;
  background-color: var(--businessflex-color-background);
  box-shadow: var(--businessflex-shadow-lg);
}

.site-content {
  flex: 1 0 auto;
  padding-top: 2.5rem;
  padding-bottom: 4rem;
}

.site-content-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

@media (min-width: 1024px) {
  .has-sidebar .site-content-layout {
    grid-template-columns: 1fr 320px;
  }
}

/* ==========================================================================
   5. Site Header & Navigation
   ========================================================================== */

.site-header {
  background-color: var(--businessflex-color-background);
  border-bottom: 1px solid var(--businessflex-color-border);
  position: relative;
  z-index: 50;
}

.header-main-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.site-branding {
  display: flex;
  flex-direction: column;
}

.site-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
}

.site-title a {
  color: var(--businessflex-color-headings);
  text-decoration: none;
}

.site-description {
  margin: 0.25rem 0 0 0;
  font-size: 0.875rem;
  color: var(--businessflex-color-muted);
}

.custom-logo-link img {
  max-height: 56px;
  width: auto;
}

/* Desktop Navigation */
.main-navigation {
  display: none;
}

@media (min-width: 1024px) {
  .main-navigation {
    display: block;
  }

  .main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 1.5rem;
  }

  .main-navigation li {
    position: relative;
  }

  .main-navigation a {
    color: var(--businessflex-color-headings);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.5rem 0;
    display: inline-block;
  }

  .main-navigation a:hover,
  .main-navigation a:focus,
  .main-navigation .current-menu-item > a {
    color: var(--businessflex-color-primary);
  }

  /* Multi-level Dropdowns */
  .main-navigation ul ul {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--businessflex-color-background);
    border: 1px solid var(--businessflex-color-border);
    border-radius: var(--businessflex-radius-md);
    box-shadow: var(--businessflex-shadow-lg);
    display: flex;
    flex-direction: column;
    min-width: 220px;
    padding: 0.5rem 0;
    gap: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--businessflex-transition);
    z-index: 100;
  }

  .main-navigation li:hover > ul,
  .main-navigation li:focus-within > ul {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .main-navigation ul ul a {
    padding: 0.5rem 1.25rem;
    display: block;
    width: 100%;
  }

  .main-navigation ul ul a:hover {
    background-color: var(--businessflex-color-surface-alt);
  }

  .main-navigation ul ul ul {
    top: 0;
    left: 100%;
  }
}

/* Mobile Menu Toggle */
.menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: transparent;
  border: 1px solid var(--businessflex-color-border);
  border-radius: var(--businessflex-radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--businessflex-color-headings);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

@media (min-width: 1024px) {
  .menu-toggle {
    display: none;
  }
}

.menu-toggle-icon {
  width: 20px;
  height: 14px;
  position: relative;
  display: inline-block;
}

.menu-toggle-icon span,
.menu-toggle-icon::before,
.menu-toggle-icon::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  left: 0;
  transition: var(--businessflex-transition);
}

.menu-toggle-icon::before { top: 0; }
.menu-toggle-icon span { top: 6px; }
.menu-toggle-icon::after { bottom: 0; }

/* Mobile Navigation Drawer */
.mobile-navigation-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 360px;
  background-color: var(--businessflex-color-background);
  box-shadow: var(--businessflex-shadow-lg);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow-y: auto;
}

.mobile-navigation-drawer.is-active {
  transform: translateX(0);
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--businessflex-color-border);
}

.mobile-drawer-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--businessflex-color-headings);
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-navigation ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-navigation li {
  border-bottom: 1px solid var(--businessflex-color-border);
}

.mobile-navigation a {
  display: block;
  padding: 0.75rem 0;
  font-weight: 600;
  color: var(--businessflex-color-headings);
  text-decoration: none;
}

.mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  z-index: 9998;
}

.mobile-drawer-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   6. Content, Posts & Cards
   ========================================================================== */

.page-header,
.entry-header {
  margin-bottom: 2rem;
}

.page-title,
.entry-title {
  margin-top: 0;
  font-size: 2.25rem;
  line-height: 1.2;
}

.entry-meta {
  color: var(--businessflex-color-muted);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.entry-content {
  line-height: 1.75;
}

.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .posts-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.post-card {
  background-color: var(--businessflex-color-background);
  border: 1px solid var(--businessflex-color-border);
  border-radius: var(--businessflex-radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--businessflex-transition);
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--businessflex-shadow-md);
  border-color: #94A3B8;
}

.post-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.post-card-title {
  font-size: 1.25rem;
  margin: 0 0 0.75rem 0;
}

.post-card-title a {
  color: var(--businessflex-color-headings);
  text-decoration: none;
}

.post-card-title a:hover {
  color: var(--businessflex-color-primary);
}

.post-card-excerpt {
  color: var(--businessflex-color-text);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
  flex-grow: 1;
}

/* ==========================================================================
   7. Buttons & Form Controls
   ========================================================================== */

button,
input[type="button"],
input[type="reset"],
input[type="submit"],
.button,
.wp-block-button__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--businessflex-color-primary);
  color: #FFFFFF !important;
  border: 1px solid transparent;
  border-radius: var(--businessflex-radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: var(--businessflex-transition);
}

button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover,
.button:hover,
.wp-block-button__link:hover {
  background-color: var(--businessflex-color-primary-hover);
  text-decoration: none;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="range"],
input[type="date"],
input[type="month"],
input[type="week"],
input[type="time"],
input[type="datetime"],
input[type="datetime-local"],
input[type="color"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--businessflex-color-border);
  border-radius: var(--businessflex-radius-sm);
  background-color: var(--businessflex-color-background);
  color: var(--businessflex-color-text);
  font-size: 1rem;
  line-height: 1.5;
  transition: border-color 0.15s ease-in-out;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--businessflex-color-primary);
  outline: 2px solid rgba(29, 78, 216, 0.2);
}

/* ==========================================================================
   8. Sidebar & Widgets
   ========================================================================== */

.widget-area .widget {
  margin-bottom: 2.5rem;
}

.widget-title {
  font-size: 1.15rem;
  margin-top: 0;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--businessflex-color-border);
}

.widget ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.widget li {
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--businessflex-color-border);
}

.widget a {
  text-decoration: none;
}

/* ==========================================================================
   9. Footer & Back-to-Top
   ========================================================================== */

.site-footer {
  background-color: #0F172A;
  color: #94A3B8;
  margin-top: auto;
  border-top: 1px solid #1E293B;
}

.site-footer h1, .site-footer h2, .site-footer h3, .site-footer h4, .site-footer h5, .site-footer h6 {
  color: #F8FAFC;
}

.site-footer a {
  color: #E2E8F0;
  text-decoration: none;
}

.site-footer a:hover {
  color: #60A5FA;
}

.footer-widgets {
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
}

.footer-widgets-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

@media (min-width: 768px) {
  .footer-widgets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .footer-widgets-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.footer-bottom {
  border-top: 1px solid #1E293B;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  font-size: 0.875rem;
}

.footer-bottom-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

@media (min-width: 768px) {
  .footer-bottom-inner {
    flex-direction: row;
  }
}

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--businessflex-color-primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  box-shadow: var(--businessflex-shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: var(--businessflex-transition);
  z-index: 99;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background-color: var(--businessflex-color-primary-hover);
}
