/* ==============================================
   Data Diaries — Global Stylesheet
   Brand: Simply Shilp | datadiaries.in
   ============================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Sans:wght@400;500;600&display=swap');

/* --- Design Tokens --- */
:root {
  --color-primary-teal:     #2DBD9A;
  --color-primary-blue:     #4A90D9;
  --color-gradient-mid:     #3AABBC;
  --color-text-primary:     #1A1A2E;
  --color-text-secondary:   #5A5A72;
  --color-background:       #FFFFFF;
  --color-surface:          #F7F9FC;
  --color-border:           #E8ECF2;
  --color-accent-light:     #E6F7F3;

  --font-serif:  'DM Serif Display', serif;
  --font-sans:   'DM Sans', sans-serif;

  --max-width-narrative:  780px;
  --max-width-dashboard:  1100px;
  --radius:               8px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  background: var(--color-background);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 400;
  line-height: 1.25;
}

h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.35;
}

h3 {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.5;
}

a {
  color: var(--color-primary-blue);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-primary-teal);
}

img {
  max-width: 100%;
  display: block;
}

/* --- Layout Utilities --- */
.container {
  max-width: var(--max-width-narrative);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container--wide {
  max-width: var(--max-width-dashboard);
}

.section {
  padding: 3rem 0;
}

/* --- Navigation --- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width-dashboard);
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--color-text-primary);
}

.nav__logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.nav__title {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 1.1rem;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav__links a {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.nav__links a:hover,
.nav__links a.active {
  color: var(--color-primary-teal);
}

/* Hamburger (mobile) */
.nav__toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}

.nav__toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text-primary);
  margin: 5px 0;
  transition: 0.3s;
}

@media (max-width: 768px) {
  .nav__toggle {
    display: block;
  }

  .nav__links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    right: 1.5rem;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 100;
  }

  .nav__links.open {
    display: flex;
  }
}

header {
  position: relative;
  border-bottom: 1px solid var(--color-border);
}

/* --- Card --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.card--featured {
  border-left: 4px solid var(--color-primary-teal);
}

/* --- Tag Pill --- */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  background: var(--color-accent-light);
  color: var(--color-primary-teal);
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn--primary {
  background: var(--color-primary-teal);
  color: #fff;
}

.btn--primary:hover {
  background: #2E6AB0;
}

.btn--outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.btn--outline:hover {
  border-color: var(--color-primary-teal);
  color: var(--color-primary-teal);
}

/* --- Story Link Arrow --- */
.story-link {
  font-weight: 500;
  color: var(--color-primary-teal);
  font-size: 0.95rem;
}

.story-link:hover {
  color: #2E6AB0;
}

/* --- Meta text --- */
.meta {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 5rem 1.5rem 3.5rem;
}

@media (max-width: 768px) {
  .hero {
    padding: 3rem 1.25rem 2rem;
  }
  .hero h1 {
    font-size: 1.7rem;
  }
  .hero p {
    font-size: 1rem;
  }
}

.hero h1 {
  margin-bottom: 0.75rem;
}

.hero p {
  color: var(--color-text-secondary);
  font-size: 1.1rem;
  max-width: 520px;
  margin: 0 auto;
}

/* --- Stories Grid --- */
.stories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .stories-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Compact Story Row --- */
.story-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.story-row:last-child {
  border-bottom: none;
}

.story-row h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 400;
  flex: 1;
}

@media (max-width: 768px) {
  .story-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
}

/* --- About Strip --- */
.about-strip {
  background: var(--color-surface);
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.about-strip p {
  max-width: 560px;
  margin: 0 auto 1rem;
  color: var(--color-text-secondary);
}

.about-strip a {
  color: var(--color-primary-blue);
  font-weight: 500;
}

/* --- About Page --- */
.about-page {
  text-align: center;
  padding: 4rem 1.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.about-page__logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 2rem;
}

.about-page h1 {
  margin-bottom: 1.5rem;
}

.about-page p {
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

.about-page .tagline {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-text-primary);
  margin: 1.5rem 0;
}

/* --- LinkedIn Button --- */
.linkedin-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  background: #0A66C2;
  color: #fff;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.linkedin-btn:hover {
  background: #004182;
  color: #fff;
}

/* --- View All Link --- */
.view-all {
  display: block;
  text-align: center;
  margin-top: 1.5rem;
  font-weight: 500;
  color: var(--color-primary-teal);
}

/* --- Stories Listing --- */
.stories-page__header {
  padding: 3rem 0 1.5rem;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.filter-tab {
  padding: 0.35rem 1rem;
  border-radius: 100px;
  border: 1px solid var(--color-border);
  background: var(--color-background);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-tab:hover,
.filter-tab.active {
  background: var(--color-accent-light);
  border-color: var(--color-primary-teal);
  color: var(--color-primary-teal);
}

/* --- Chat Interface --- */
.chat-container {
  max-width: var(--max-width-narrative);
  margin: 0 auto;
}

.chat-messages {
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  padding: 1rem 0;
}

.chat-msg {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  max-width: 85%;
}

/* AI response formatting */
.chat-msg--ai p {
  white-space: pre-wrap;
}
.chat-msg--ai strong {
  font-weight: 600;
  color: var(--color-text-primary);
}
.chat-msg--ai ul, .chat-msg--ai ol {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}
.chat-msg--ai li {
  margin-bottom: 0.25rem;
}
.chat-msg--ai code {
  background: var(--color-accent-light);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}
.chat-msg--ai .data-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.4rem;
}
.chat-msg--ai .data-label--data {
  background: var(--color-accent-light);
  color: var(--color-primary-teal);
}
.chat-msg--ai .data-label--general {
  background: #EEF2FF;
  color: var(--color-primary-blue);
}

@media (max-width: 768px) {
  .chat-msg {
    max-width: 95%;
  }
  .chat-messages {
    min-height: 200px;
  }
}

.chat-msg--user {
  background: var(--color-accent-light);
  margin-left: auto;
}

.chat-msg--ai {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.chat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
  color: var(--color-primary-teal);
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.chat-input {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: var(--color-primary-teal);
}

.suggested-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.suggested-prompt {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 100px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.suggested-prompt:hover {
  border-color: var(--color-primary-teal);
  color: var(--color-primary-teal);
}

/* --- Mobile Responsive Enhancements --- */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }
  h1 {
    font-size: 1.75rem;
  }
  h2 {
    font-size: 1.35rem;
  }
  .section {
    padding: 2rem 0;
  }
  .container {
    padding: 0 1.25rem;
  }
  .card {
    padding: 1.25rem;
  }
  .filter-tabs {
    gap: 0.4rem;
  }
  .filter-tab {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
  }
  .about-strip {
    padding: 2rem 1.25rem;
  }
  .about-page {
    padding: 2.5rem 1.25rem;
  }
  .stories-page__header {
    padding: 2rem 0 1rem;
  }
  .suggested-prompts {
    flex-direction: column;
  }
  .suggested-prompt {
    text-align: center;
  }
  .chat-input-row {
    flex-direction: column;
  }
  .chat-input-row .btn {
    width: 100%;
  }
}

/* --- Admin Mobile --- */
@media (max-width: 768px) {
  .admin-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
  }
  .admin-tab {
    white-space: nowrap;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
  .admin-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.8rem;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* --- Floating Simply Ask --- */
.sa-float-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-primary-blue);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(74,144,217,0.35);
  z-index: 999;
  transition: transform 0.2s, box-shadow 0.2s;
}
.sa-float-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(74,144,217,0.45);
}
.sa-float-btn--hidden { opacity: 0; pointer-events: none; }
.sa-float-label { display: inline; }
@media (max-width: 480px) {
  .sa-float-label { display: none; }
  .sa-float-btn { padding: 0.85rem; border-radius: 50%; }
}

.sa-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 400px;
  max-height: 560px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.sa-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (max-width: 480px) {
  .sa-panel {
    width: calc(100% - 1rem);
    right: 0.5rem;
    bottom: 0.5rem;
    max-height: 80vh;
  }
}

.sa-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary-blue);
  color: #fff;
  border-radius: 12px 12px 0 0;
}
.sa-panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
}
.sa-panel-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
}
.sa-panel-close:hover { opacity: 1; }

.sa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  min-height: 180px;
  max-height: 320px;
}

.sa-msg {
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.6;
  max-width: 90%;
}
.sa-msg--user {
  background: #EEF2FF;
  margin-left: auto;
  color: var(--color-text-primary);
}
.sa-msg--ai {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.sa-msg--ai p { white-space: pre-wrap; margin: 0; }
.sa-msg--ai strong { font-weight: 600; }
.sa-msg--ai ul, .sa-msg--ai ol { padding-left: 1.1rem; margin: 0.3rem 0; }
.sa-msg--ai li { margin-bottom: 0.15rem; }

.sa-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--color-border);
}
.sa-suggestion {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 100px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.sa-suggestion:hover {
  border-color: var(--color-primary-blue);
  color: var(--color-primary-blue);
}

.sa-input-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--color-border);
}
.sa-input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  outline: none;
}
.sa-input:focus { border-color: var(--color-primary-blue); }
.sa-send {
  background: var(--color-primary-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}
.sa-send:hover { background: #3A7BC8; }

/* --- Utilities --- */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
