/* --- Global Layout --- */
body {
    font-family: "Inter", "Arial", sans-serif;
    background: linear-gradient(180deg, #243B53 0%, #1E2E42 100%);
    color: #fff;
    text-align: center;
    margin: 0;
    padding: 0;
}

/* --- Stockaroo mascot positioning fine-tuned --- */
.stockaroo-hero {
  position: relative;
  top: 85px;          /* was 55px — lower it by another 20px */
  left: -40px;
  max-width: 1200px;
  margin: 0 auto;
  text-align: left;
  z-index: 2;
}

.stockaroo-img {
  height: 140px;
  width: auto;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.3));
}

/* Center the mascot on mobile */
@media (max-width: 640px) {
  .stockaroo-hero {
    top: 10px;
    left: 0;
    text-align: center;
  }
  .stockaroo-img {
    height: 120px;
  }
}

/* Make all content feel centered and clean */
.container {
    margin: 30px auto;
    max-width: 1200px;
}

/* Headings */
h1, h2, h3 {
    color: #ffffff;
    margin-top: 20px;
}

/* --- Tables --- */
table {
    margin: 20px auto;
    border-collapse: collapse;
    width: 80%;
    background: #ffffff;
    color: #111;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

th, td {
    border: 1px solid #ddd;
    padding: 10px;
}

th {
    background-color: #E9EEF7;
    color: #2F5C8F;
}

/* --- Header Bar --- */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #2F5C8F;
    padding: 15px 30px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.welcome {
    font-size: 15px;
    color: #e4e7ed;
    font-weight: 500;
}

/* --- Header Links (Clean White Underlined) --- */
.header-actions a {
    color: #ffffff;
    text-decoration: underline;
    font-size: 16px;
    font-weight: 500;
    padding: 0 14px;
    transition: color 0.2s ease;
    vertical-align: middle;
}
.header-actions a:hover {
    color: #BFD9FF;
    text-decoration: underline;
}

/* --- Run Stock Forecast (multiline link) --- */
.forecast-link {
    display: inline-block;
    text-align: center;
    line-height: 1.2;
    white-space: pre-line;
    font-weight: 600;
}

/* --- Add & Search Buttons --- */
.save-btn {
    background: #2F5C8F;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}
.save-btn:hover {
    background: #366DA9;
}

/* --- Inputs --- */
form input {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    outline: none;
}
form input:focus {
    border-color: #1B3C73;
    box-shadow: 0 0 4px rgba(27,60,115,0.4);
}

/* --- Search Form --- */
.search-form {
    margin: 15px 0;
}

/* --- Stock Status Badges --- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}
.badge-urgent { background: #d32f2f; }   /* red */
.badge-low { background: #f9a825; color: #000; } /* amber */
.badge-healthy { background: #388e3c; }  /* green */
.badge-out { background: #6d4c41; }      /* brown */

/* --- Action Buttons --- */
.action-btn {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 6px;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transition: 0.2s;
}
.action-in { background: #3FA86C; }   /* green */
.action-out { background: #D94848; }  /* red */
.action-btn:hover { opacity: 0.85; }

/* --- Delete Button --- */
.delete-btn {
    background: transparent;
    color: #ff4b4b;
    border: none;
    font-size: 15px;
    cursor: pointer;
    transition: 0.2s;
}
.delete-btn:hover {
    color: #c40000;
    text-decoration: underline;
}

/* --- Legend --- */
.legend {
    margin-top: 15px;
    font-size: 14px;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

/* --- Close Button --- */
#closeAiBtn {
    background-color: #1B3C73;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    cursor: pointer;
    transition: 0.2s;
    display: block;
    margin: 25px auto 0;
}
#closeAiBtn:hover {
    background-color: #142B52;
}

/* --- Modal (Add Product Window) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: #fff;
    margin: 12% auto;
    padding: 25px 30px;
    border-radius: 12px;
    width: 360px;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.3);
    color: #111;
    text-align: center;
}

.modal-content h3 {
    color: #1B3C73;
    margin-bottom: 20px;
}

.modal-content input {
    width: 85%;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid #ccc;
    border-radius: 6px;
    outline: none;
}

.modal-content input:focus {
    border-color: #1B3C73;
    box-shadow: 0 0 5px rgba(27, 60, 115, 0.3);
}

.modal-actions {
    margin-top: 15px;
    display: flex;
    justify-content: space-around;
}

.modal-actions .plain-btn {
    background-color: #2F5C8F;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-actions .plain-btn:hover {
    background-color: #366DA9;
}

/* --- Auth Pages (Login & Signup) --- */
.auth-container {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.3);
    width: 320px;
    margin: 80px auto;
    padding: 30px;
    text-align: center;
    color: #111;
}

.auth-container h2 {
    margin-bottom: 15px;
    color: #1B3C73;
}

.auth-container input {
    width: 90%;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.auth-container button {
    margin-top: 10px;
    padding: 8px 18px;
    background-color: #1B3C73;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}
.auth-container button:hover {
    background-color: #142B52;
}

.auth-alt {
    margin-top: 10px;
    font-size: 14px;
}
.auth-alt a {
    color: #1B3C73;
    text-decoration: none;
    font-weight: 600;
}
.auth-alt a:hover {
    text-decoration: underline;
}

/* --- Mobile-friendly login/signup boxes --- */
@media (max-width: 480px) {
  .auth-container {
    width: 85%;
    padding: 20px 15px;
    margin: 60px auto;
  }

  .auth-container h2 {
    font-size: 20px;
  }

  .auth-container input,
  .auth-container button {
    font-size: 15px;
  }
}

/* Flash messages */
.flash {
    padding: 8px;
    border-radius: 6px;
    margin: 10px auto;
    width: 80%;
    text-align: center;
}
.flash.success { background-color: #d4edda; color: #155724; }
.flash.danger { background-color: #f8d7da; color: #721c24; }
.flash.info { background-color: #cce5ff; color: #004085; }

.ai-output {
    background: #fff;
    border-radius: 12px;
    padding: 25px 35px;
    margin: 40px auto;
    width: 85%;
    max-width: 900px;
    color: #111;
    text-align: left;
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
}
.ai-output pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: "Inter", "Arial", sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #111;
}
.ai-output em {
    font-style: italic;
    color: #333;
}

/* --- Final AI Forecast Box Adjustments --- */
.ai-output {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
    padding: 25px 35px;
    margin: 40px auto;
    width: 85%;
    max-width: 900px;
    color: #111;
    text-align: left;
}
.ai-output h3 {
    color: #1B3C73;
    text-align: center;
    font-size: 21px;
    font-weight: 700;
    margin-bottom: 15px;
    border-bottom: 2px solid #eee;
    padding-bottom: 8px;
}

/* --- AI Forecast Clean Fix --- */
.ai-output pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: "Inter", "Arial", sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #111;
    margin: 0;
    padding: 0;
}

/* Remove unwanted bullets or list dots */
.ai-output pre ul,
.ai-output pre li {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Align product names neatly */
.ai-output strong {
    font-weight: 600;
    color: #000;
}

.ai-output em {
    font-style: italic;
    color: #333;
}

/* --- Dashboard layout adjustment (lift Inventory + table up) --- */
.dashboard-content {
    position: relative;
    top: -45px;  /* Move everything up */
}

/* --- Ask Stockaroo Speech Bubble (precisely aligned to current mascot) --- */
.ask-stockaroo {
  position: absolute;
  top: 220px;       /* vertically aligned to mouth area */
  left: 180px;      /* distance from mascot’s left edge */
  z-index: 3;
}

.bubble {
  position: relative;
  display: inline-block;
  background: #ffffff;
  color: #1B3C73;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: 0.2s ease;
}

/* Speech bubble tail pointing toward the kangaroo’s mouth */
.bubble::after {
  content: "";
  position: absolute;
  bottom: 6px;
  left: -7px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-right-color: #ffffff;
}

/* Hover feedback */
.bubble:hover {
  background: #E8F1FF;
  transform: translateY(-1px);
}

/* Prevent kangaroo image from blocking clicks, but keep Ask Stockaroo clickable */
.stockaroo-hero {
  pointer-events: none; /* Kangaroo itself won't block clicks */
}

.ask-stockaroo {
  pointer-events: auto; /* The bubble remains clickable */
  z-index: 5000; /* stays above dashboard but below modals */
}

/* Ensure modal always stays on top of everything */
.modal {
  z-index: 9999 !important;
}

/* --- Fix for all clickable buttons to show hand cursor --- */
button,
.save-btn,
.action-btn,
.delete-btn,
.plain-btn,
#aiSendBtn,
#closeAiChat {
  cursor: pointer;
}

/* --- Mobile layout for Stockaroo mascot and Ask button --- */
@media (max-width: 640px) {
  .stockaroo-hero {
    position: relative;
    top: 20px;          /* move it higher */
    left: 30px;     /* shift left */
    text-align: left;
  }

  .stockaroo-img {
    height: 90px;    /* smaller mascot */
    width: auto;
  }

  .ask-stockaroo {
    top: 142px;       /* move bubble closer to mascot mouth */
    left: 83px;       /* align bubble right next to kangaroo */
    transform: none;
  }

  .bubble {
    font-size: 11px;  /* slightly smaller text */
    padding: 4px 8px;
    border-radius: 14px; /* keeps it smooth and compact */
  }

  .bubble::after {
    display: block;
    bottom: 3px;
    left: -5px;
    border-width: 5px;
  }
}

/* --- Mobile-friendly AI Chat Modal --- */
@media (max-width: 640px) {
  #aiChatModal .modal-content {
    width: 90% !important;       /* keep margins on sides */
    max-width: 90% !important;
    margin: 30% auto !important; /* center vertically with breathing space */
    border-radius: 12px;         /* round corners */
    padding: 20px 15px !important;
  }

.calc-btn {
  width: 60px;
  height: 50px;
  margin: 3px;
  font-size: 20px;
  border-radius: 8px;
  border: none;
  background: #f4f4f4;
  cursor: pointer;
  transition: background 0.2s;
}
.calc-btn:hover {
  background: #e0e0e0;
}

/* --- Mobile layout refinements (10/2025 update) --- */
html, body {
  overflow-x: hidden;   /* Prevent sideways scrolling */
  max-width: 100%;
}

/* Apply only to smaller screens */
@media (max-width: 640px) {
  /* Make the Forecast title narrower and centered */
  .dashboard-content h2 {
    margin-left: 5px;
    margin-right: 5px;
    text-align: center;
    word-wrap: break-word;
    font-size: 17px;
  }

  /* Add spacing between quantity box and buttons */
  td input[type="number"] {
    display: block;
    margin: 0 auto 8px auto;
  }

  td .action-btn {
    margin: 3px 5px;
  }
}

/* --- Mobile Responsive Fix for All Modals --- */
@media (max-width: 640px) {
  #aiChatModal .modal-content,
  #subscribeModal .modal-content,
  #unsubscribeModal .modal-content,
  #addProductModal .modal-content {
    width: 85% !important;       /* adds slight side margins */
    max-width: 380px !important; /* keeps consistent size */
    margin: 35% auto !important; /* perfect vertical centering */
    border-radius: 12px;         /* smooth rounded corners */
    padding: 20px 18px !important; /* even inner padding */
  }
}

/* --- Fine-tune header link spacing on mobile --- */
@media (max-width: 640px) {
  .header-actions {
    position: relative;
    right: -8px; /* shift links slightly to the right */
  }

  .header-actions a {
    margin-left: 10px; /* add small gap between each link */
    letter-spacing: 0.3px;
  }
}
