/* ===== 1. THEME & VARIABLES ===== */
/* Defines all colors and styles for easy theme management. */
:root {
    /* -- DARK THEME (DEFAULT) -- */
    --font-main: sans-serif;
  
    /* Backgrounds */
    --bg-card: rgba(60, 20, 60, 0.7);
    --bg-card-locked: rgba(80, 30, 60, 0.5);
    --bg-modal-overlay: rgba(50, 10, 50, 0.85);
    --bg-modal-content: rgba(60, 20, 60, 0.9);
    --bg-close-hover: rgba(255, 255, 255, 0.1);
    
    /* Text Colors */
    --text-primary: #ffe6f0;
    --text-header: #ffb3d9;
    --text-locked: #d499c4;
  
    /* Shadows & Effects */
    --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.4);
    --shadow-card-hover: 0 15px 35px rgba(255, 150, 200, 0.5);
    --backdrop-blur: blur(10px);
  
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-med: 0.3s ease;
    --transition-slow: 0.4s ease;
  }
  
  body.light-mode {
    /* -- REFINED LIGHT THEME -- */
    
    /* 1. Set a main page background color. This is the foundation. */
    background-color: #f7f5f9; /* A very light, soft lavender-grey */
  
    /* 2. Make card backgrounds solid white to stand out. */
    --bg-card: #ffffff;
    --bg-card-locked: #fdfcff; /* A slightly off-white for locked cards */
    --bg-modal-content: #ffffff;
    
    /* 3. Increase text contrast for better readability. */
    --text-primary: #3d3d3d; /* A darker, softer black */
    --text-header: #9c4b7b;  /* A deeper, more vibrant version of your pink/purple */
    --text-locked: #ad8ebc;  /* A lighter purple for locked text */
  
    /* 4. Add a specific hover color for light mode. */
    --bg-close-hover: rgba(0, 0, 0, 0.07); /* A subtle dark overlay */
  
    /* 5. Keep the nice bright shadow effect. */
    --shadow-card-hover: 0 15px 35px rgba(255, 120, 180, 0.5);
  }
  
  /* You also need to adjust the info-note background for the new theme */
  body.light-mode .info-note {
    background: #ede9f2; /* A slightly darker lavender */
    border-left-color: var(--text-header);
  }
  
  /* ===== 2. LAYOUT & GRID ===== */
  /* Add this to style the header */
 .messages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 900px;
    margin: 10px auto 20px auto; /* Top margin, centers, bottom margin */
    padding: 0 20px;
  }

  .messages-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 900px;
    margin: 0 auto 60px auto;
    padding: 0 20px;
  }
  
  /* Add this new rule right below your .messages-grid style */

   .messages-grid.grid-view-active {
    display: grid;
    /* This powerful line creates a responsive grid automatically */
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  }
  
  /* ===== 2A. LAYOUT TOGGLE BUTTON ===== */
#layout-toggle-btn {
    /* Sizing and Shape */
    width: 44px;
    height: 44px;
    border-radius: 50%; /* Makes it a circle */
    
    /* Centering the icon inside */
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* Appearance */
    border: 1px solid var(--text-header); /* Use theme color for border */
    background-color: transparent;
    cursor: pointer;
    
    /* Smooth hover effect */
    transition: background-color var(--transition-fast);
  }
  
  #layout-toggle-btn:hover {
    background-color: var(--bg-close-hover); /* Re-using the modal close hover color */
  }
  
  /* Style for the SVG icons inside the button */
  #layout-toggle-btn svg {
    /* Set icon color using our theme variable */
    fill: var(--text-header);
    width: 24px;
    height: 24px;
  }
  
  /* --- Icon Switching Logic --- */
  /* By default, show the GRID icon and hide the LIST icon */
  #layout-toggle-btn .icon-list {
    display: none;
  }
  #layout-toggle-btn .icon-grid {
    display: block;
  }
  
  /* When the body has the .grid-view-active class, flip the icons */
  body.grid-view-active #layout-toggle-btn .icon-grid {
    display: none;
  }
  body.grid-view-active #layout-toggle-btn .icon-list {
    display: block;
  }

  /* ===== 3. MESSAGE CARD STYLES ===== */
  .message-card {
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 20px;
    box-shadow: var(--shadow-card);
    padding: 25px 30px;
    cursor: pointer;
    transition: transform var(--transition-med), box-shadow var(--transition-med);
  }
  
  .message-card:not(.locked):hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-card-hover);
  }
  
  .message-card h3 {
    margin: 0 0 10px 0;
    font-size: 1.4rem;
    color: var(--text-header);
  }
  
  .message-card p {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.5;
  }
  
  .message-card.locked {
    background: var(--bg-card-locked);
    cursor: not-allowed;
  }
  
  .message-card.locked p {
    font-style: italic;
    color: var(--text-locked);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  
  /* ===== 4. MODAL STYLES ===== */
  .modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-modal-overlay);
    backdrop-filter: var(--backdrop-blur);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
  }
  
  .modal.active {
    opacity: 1;
    visibility: visible;
  }
  
  .modal-content-box {
    background: var(--bg-modal-content);
    color: var(--text-primary);
    padding: 30px;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    position: relative;
    text-align: center;
  }

  .modal-content {
    /* This is the key part! */
    max-height: 60vh;   /* Limit the height to 60% of the viewport's height */
    overflow-y: auto;   /* Add a vertical scrollbar ONLY when needed */
  
    /* A little extra padding on the right makes room for the scrollbar */
    padding-right: 15px; 
    text-align: left;     /* Align long paragraphs to the left for easier reading */
  }
  
  .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
  }
  
  .modal-close:hover {
    background-color: var(--bg-close-hover);
    transform: scale(1.1);
  }
  
  #layout-toggle-btn:hover, .modal-close:hover {
    cursor: url('../images/cursor/hover.png') 16 16, pointer;
  }
  
  /* ===== 5. RESPONSIVE DESIGN ===== */
  @media (max-width: 768px) {
    .messages-grid {
      padding: 0 15px;
    }
    .message-card {
      padding: 20px;
    }
    .message-card h3 {
      font-size: 1.2rem;
    }
    .message-card p {
      font-size: 1rem;
    }
  }
  
  @media (max-width: 500px) {
    .message-card {
      padding: 15px;
    }
    .message-card h3 {
      font-size: 1.1rem;
    }
    .message-card p {
      font-size: 0.95rem;
    }
  }

  /* ===== 2B. INFO NOTE BOX ===== */
.info-note {
    /* Sizing and Positioning */
    max-width: 900px;
    margin: 0 auto 40px auto; /* Centers it and adds space below */
    padding: 20px 25px;
    
    /* Appearance */
    background: rgba(80, 30, 60, 0.6); /* Slightly different from cards */
    color: var(--text-primary);
    border-left: 4px solid var(--text-header); /* Accent line */
    border-radius: 15px;
    
    /* Flexbox for icon and text alignment */
    display: flex;
    align-items: center;
    gap: 15px;
  }
  
  .info-note p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
  }
  
  /* Style for the SVG icon inside the note */
  .info-note svg {
    fill: var(--text-header);
    width: 28px;
    height: 28px;
    flex-shrink: 0; /* Prevents the icon from squishing on small screens */
  }
