/* Reset basic page styles */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

/* ------------------------
   App Shell
   ------------------------ */
.gatewood-ai-app {
  display: flex;
  height: 100svh;       /* full viewport height */
  min-height: 100vh;    /* fallback for iOS Safari */
  width: 100%;
  overflow: hidden;
  background: #0b0b0b;
  color: #fff;
  font-family: Arial, sans-serif;
}

/* ------------------------
   Sidebar
   ------------------------ */
.agent-sidebar {
  width: 220px;          /* fixed width on desktop */
  background: #111;
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;        /* do not collapse */
  overflow-y: auto;
  z-index: 10;           /* above iframe if needed */
  box-sizing: border-box;
}

.agent-sidebar button {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: #222;
  color: #fff;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  border-radius: 4px;
  transition: background 0.2s;
}

.agent-sidebar button:hover {
  background: #333;
}

/* ------------------------
   Main agent view
   ------------------------ */
.agent-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#agent-title {
  padding: 12px 16px;
  font-size: 1.1rem;
  border-bottom: 1px solid #222;
  background: #111;
}

#agent-frame {
  flex: 1;
  width: 100%;
  border: none;
}

/* ------------------------
   Mobile / small screens
   ------------------------ */
@media (max-width: 768px) {
  .gatewood-ai-app {
    flex-direction: column;   /* sidebar on top */
    height: 100svh;
    min-height: 100vh;
  }

  .agent-sidebar {
    flex-direction: row;      /* buttons horizontal */
    overflow-x: auto;
    width: 100%;
    padding: 8px;
  }

  .agent-sidebar button {
    flex: 0 0 auto;           /* do not shrink */
    margin-right: 8px;
    margin-bottom: 0;
  }

  .agent-view {
    flex: 1;
    min-width: 0;
  }

  #agent-title {
    padding: 8px 12px;
    font-size: 1rem;
  }
}

/* ------------------------
   Optional: scrollbar styling for mobile
   ------------------------ */
.agent-sidebar::-webkit-scrollbar {
  height: 6px;
}

.agent-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

/* ===== MOBILE FIX ===== */
@media (max-width: 768px) {

  /* Stack layout instead of sidebar */
  .gatewood-ai-app {
    flex-direction: column;
    height: 100svh;
  }

  /* Sidebar becomes top nav */
  .agent-sidebar {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
  }

  .agent-sidebar button {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 12px 16px;
    font-size: 14px;
  }

  /* Main content fills remaining space */
  .agent-view {
    flex: 1;
    width: 100%;
    padding: 0;
  }

  #agent-title {
    padding: 12px;
    font-size: 16px;
  }

  #agent-frame {
    width: 100%;
    height: calc(100svh - 100px); /* header + tabs */
  }
}

/* ===== iOS GUTENBERG IFRAME FIX ===== */
@media (max-width: 768px) {

  /* Stop viewport units inside iframe */
  #agent-frame {
    height: calc(100vh - 56px) !important;
    min-height: 600px;
  }

  .gatewood-ai-app {
    display: flex;
    flex-direction: column;
    height: auto !important;
    min-height: 100%;
    width: 100%;
  }

  .agent-sidebar {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }

  .agent-sidebar button {
    flex: 0 0 auto;
    min-width: max-content;
  }

  .agent-view {
    flex: 1;
    width: 100%;
    min-height: 400px;
  }

}

@media (max-width: 768px) {
  .wp-block-html,
  .wp-block-group,
  .wp-site-blocks {
    max-width: 100% !important;
    padding: 0 !important;
  }
}

/* ===== GATEWOOD AI MOBILE FORCE OVERRIDE ===== */
@media (max-width: 768px) {

  /* Isolate from theme + Gutenberg */
  .gatewood-ai-app,
  .gatewood-ai-app * {
    box-sizing: border-box;
  }

  .gatewood-ai-app {
    all: unset;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    position: relative;
  }

  /* Sidebar becomes TOP nav */
  .agent-sidebar {
    all: unset;
    display: flex !important;
    flex-direction: row !important;
    width: 100% !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    border-bottom: 1px solid #e5e7eb;
  }

  .agent-sidebar button {
    flex: 0 0 auto !important;
    margin: 0 6px;
  }

  /* Content area */
  .agent-view {
    all: unset;
    display: block !important;
    width: 100% !important;
    padding: 0;
  }

  /* Agent iframe */
  #agent-frame {
    display: block !important;
    width: 100% !important;
    height: 70vh !important;
    min-height: 480px;
    border: none;
  }
}
