/*
 * General Styles & Variables
 * -------------------------------------------------------------------------- */
:root {
  --background-dark: #323130;
  --panel-dark: #1b1b1b;
  --accent-yellow: #f2c811;
  --accent-yellow-light: #ffd700;
  --text-light: #e0e0e0; /* Slightly off-white for softer look */
  --text-muted: #777777; /* For footnotes or secondary info */
  --button-default-bg: white;
  --button-default-text: #333333; /* Darker text for white buttons */
  --google-blue: #4285f4;
  --google-blue-hover: #357ae8;

  --border-radius-default: 15px;
  --border-radius-small: 8px;

  --transition-speed: 0.25s;
  --spacing-xxs: 5px; /* Extra extra small spacing */
  --spacing-xs: 10px; /* Extra small spacing */
  --spacing-small: 15px; /* Small spacing */
  --spacing-medium: 20px; /* Medium spacing */
  --spacing-large: 40px; /* Large spacing */
}

/*
  *** MODIFIED: Base styles for html and body for full-height layouts and scroll control ***
  - 'height: 100%' is important.
  - 'overflow-x: hidden' prevents horizontal scroll.
  - REMOVED 'display: flex' from body to allow fixed positioning of the loading screen to work correctly.
  - ADDED 'overflow: hidden' to body by default, to prevent scrolling while loading. JS will remove it.
*/
html,
body {
  margin: 0;
  padding: 0;
  height: 100%; /* Ensures 100% height refers to viewport */
  overflow-x: hidden; /* Prevents horizontal scrollbars from appearing */
  font-family: Verdana, Arial, sans-serif;
  background-color: var(--background-dark);
  color: var(--text-light);
  min-height: 100vh; /* Ensure body takes full height for content layout */
  /*overflow: hidden; /* Prevent scrolling by default until JS handles it */
}

/* Base link styles */
a {
  text-decoration: none;
  color: var(--text-light);
  display: block; /* Make anchors fill their parent space by default */
}

a:visited {
  color: var(--text-light);
}

a:hover {
  text-decoration: none;
}

/* Headings */
h1,
h2,
h3,
h4,
h5 {
  color: white; /* Ensure headings are pure white for prominence */
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
}

p {
  line-height: 1.5;
  margin-top: 0;
  margin-bottom: var(--spacing-xs);
}

b {
  font-weight: bold;
}

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

button {
  cursor: pointer;
  transition: background-color var(--transition-speed),
    transform var(--transition-speed), border-color var(--transition-speed),
    box-shadow var(--transition-speed);
}

/*
 * Header Section (Logos and Title)
 * -------------------------------------------------------------------------- */
.header-wrapper {
  display: flex;
  justify-content: space-between; /* Pushes logos to ends */
  align-items: center; /* Vertically centers logos and title */
  flex-wrap: wrap; /* Allow wrapping on small screens */
  padding: var(--spacing-small); /* Reduced padding */
  padding-top: var(--spacing-medium); /* More space above for top content */
  position: relative;
  z-index: 10;
  width: 100%; /* Ensure header takes full width */
  box-sizing: border-box;
}

.logo_otter,
.logo_bi {
  height: 35px; /* Keep initial height */
  width: auto; /* Allow natural scaling based on height */
  flex-shrink: 0;
  /* Max width for these PNGs to prevent over-stretching */
  max-width: 90px;
}
.logo_otter {
  margin-right: var(--spacing-small);
}
.logo_bi {
  margin-left: var(--spacing-small);
  border-radius: var(--border-radius-default);
}

.titlu_pag {
  text-align: center;
  font-size: 2.8em;
  flex-grow: 1; /* Allows title to take available space */
  min-width: 150px; /* Smallest it can be before wrapping */
  color: white;
  padding: 0 var(--spacing-xs); /* Small padding for text */
}

/* Sign Out Button Styles */
.signout-btn {
  margin-top: 20px;
  margin-bottom: 20px;
  padding: 10px 20px;
  background-color: #f44336;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  display: block;
  margin-left: auto;
  margin-right: auto;
  font-size: 16px;
  transition: background-color 0.2s ease;
}

.signout-btn:hover {
  background-color: #d32f2f;
}

/*
  *** MODIFIED: Loading screen overlay ***
  - Using 100vw/100vh for reliable full-screen coverage.
  - Should not have 'hidden' class by default in HTML.
  - Opacity and visibility handled by JS adding/removing the 'hidden' class.
*/
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw; /* Use viewport width */
  height: 100vh; /* Use viewport height */
  background-color: var(--background-dark);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999; /* Highest z-index to be on top */
  opacity: 1; /* Starts fully visible */
  visibility: visible; /* Starts visible */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none; /* Prevents interaction with the invisible overlay */
}

.loading-logo {
  width: 150px;
  height: auto;
  margin-bottom: 20px;
}

.loading-text {
  font-size: 1.2rem;
  color: var(--text-light);
  font-weight: bold;
  margin-bottom: 20px;
}

/* --- Spinner Styles --- */
/*force comments*/
.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3); /* Culoarea de bază a cercului */
  border-top: 4px solid var(--accent-yellow); /* Culoarea părții animate */
  border-radius: 50%; /* Face elementul un cerc */
  width: 40px; /* Dimensiunea spinnerului */
  height: 40px; /* Dimensiunea spinnerului */
  animation: spin 1s linear infinite; /* Animația de rotire */
  margin-top: 20px; /* Spațiu de deasupra spinnerului (dacă vrei mai mult spațiu) */
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* On smaller screens, logos stack above/below title */
@media (max-width: 768px) {
  .header-wrapper {
    flex-direction: column; /* Stack items vertically */
    padding-top: var(--spacing-medium);
    padding-bottom: var(--spacing-medium); /* Ensure enough space at bottom */
  }

  .logo_otter,
  .logo_bi {
    margin: var(--spacing-xxs) auto; /* Center logos when stacked */
    height: 30px; /* Smaller height for mobile */
    max-width: 60px; /* Smaller max-width for mobile */
  }

  .titlu_pag {
    font-size: 2em;
    margin-top: var(--spacing-small);
    margin-bottom: var(--spacing-small);
    order: -1; /* Place title first in stack on mobile */
  }
}

@media (max-width: 480px) {
  .logo_otter,
  .logo_bi {
    height: 25px;
    max-width: 50px;
  }
  .titlu_pag {
    font-size: 1.6em;
  }
}

/*
 * Main Content Containers & Layout
 * -------------------------------------------------------------------------- */
.container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  align-items: stretch;
  background-color: var(--panel-dark);
  border: 1px solid var(--accent-yellow);
  border-radius: var(--border-radius-default);
  padding: var(--spacing-xs); /* Reduced padding for container itself */
  margin: var(--spacing-medium) auto var(--spacing-large) auto;
  max-width: 90%;
  width: 95%;
  box-sizing: border-box;
  flex-grow: 1; /* Allow container to grow if content is short */
}

/* Styles for the "Choices" on index.html (MAIN MENU BUTTONS) */
.choice {
  /* Using calc for percentage, and a fixed amount for spacing */
  /* This formula (100% / N items) - (N-1 * margin / N) */
  flex: 1 1 calc(50% - var(--spacing-medium) * 2); /* Target 2 items per row */
  margin: var(--spacing-medium); /* Consistent margin around items */
  transition: transform var(--transition-speed);
  text-align: center;
  box-sizing: border-box; /* Crucial for calc to work correctly */
  max-width: calc(50% - var(--spacing-medium) * 2); /* Ensure max width doesn't exceed 50% */
  min-width: 250px; /* Minimum width before forcing wrap */
}

.choice:hover {
  transform: scale(1.03);
}

.choice button {
  width: 100%; /* Button fills its parent .choice */
  height: 280px; /* Slightly reduced height, scales with mobile */
  border-radius: var(--border-radius-default);
  border: 2px solid var(--accent-yellow);
  background-color: var(--button-default-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 2.2em;
  color: var(--button-default-text);
  box-sizing: border-box;
  padding: var(--spacing-small); /* Internal padding */
  text-align: center;
  line-height: 1.2;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.choice button:hover {
  border-color: var(--accent-yellow-light);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.choice_raport b {
  display: block;
  margin-bottom: 5px;
  font-size: 1.2em;
}

.choice_raport p {
  font-size: 0.7em;
  font-weight: normal;
  margin: 0;
  line-height: 1.3;
  color: var(--text-muted);
}

/* Styles for the "Reports" on interactive_reports.html */
.raport {
  flex: 1 1 calc(20% - var(--spacing-small) * 2); /* 5 items per row with margin */
  margin: var(--spacing-small); /* Smaller margins for more items */
  transition: transform var(--transition-speed);
  text-align: center;
  box-sizing: border-box;
  max-width: calc(25% - var(--spacing-small) * 2); /* Max 4 items on slightly smaller desktops to handle potential overflow */
  min-width: 150px; /* Smaller min-width for mobile */
  position: relative; /* Crucial for absolute positioning of .favorite-icon */
}

.raport:hover {
  transform: scale(1.03);
}

.poza_raport {
  width: 100%; /* Fill the width of its parent (.raport) */
  height: 150px; /* Adjusted height, scales with mobile */
  border-radius: var(--border-radius-default);
  border: 2px solid var(--accent-yellow);
  background-color: var(--button-default-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 1.2em;
  color: var(--button-default-text);
  box-sizing: border-box;
  padding: var(--spacing-xxs); /* Smaller internal padding */
  text-align: center;
  line-height: 1.2;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.poza_raport:hover {
  border-color: var(--accent-yellow-light);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.poza_raport b {
  display: block;
  margin-bottom: var(--spacing-xxs);
  font-size: 1.1em;
  padding: 0 var(--spacing-xxs); /* Add padding to prevent text from hitting sides */
}

.poza_raport p {
  font-size: 0.8em;
  font-weight: normal;
  margin: 0;
  line-height: 1.3;
  color: var(--text-muted);
  padding: 0 var(--spacing-xxs);
}

/*
 * Login/Auth Containers
 * -------------------------------------------------------------------------- */
#login-container {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  text-align: center;
  background-color: var(--background-dark);
  color: var(--text-light);
  padding: var(--spacing-large);
  box-sizing: border-box;
  /* MODIFIED: Initially hidden by CSS, JS will show/hide */
  display: none;
}

#content-container {
  /*
    *** MODIFIED: Changed initial display from 'none' (handled by inline HTML style now)
    *** and ensured it's a flex column to manage its own children and footer.
  */
  display: flex; /* Ensure content-container is flex to manage its own layout */
  flex-grow: 1; /* Allows content to push footer down */
  flex-direction: column; /* Stack content vertically */
  min-height: 100vh; /* Ensure it takes full height when displayed */
  /* MODIFIED: Initially hidden by CSS, JS will show/hide */
  display: none;
}

.login-logo {
  width: 120px;
  height: auto;
  margin-bottom: var(--spacing-medium);
}

.login-btn {
  background-color: var(--google-blue);
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 1.1em;
  border-radius: var(--border-radius-small);
  margin-top: var(--spacing-medium);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.login-btn:hover {
  background-color: var(--google-blue-hover);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/*
 * Footer & Miscellaneous
 * -------------------------------------------------------------------------- */
.footnote {
  font-size: 0.8em;
  color: var(--text-muted);
  text-align: center;
  margin-top: auto; /* Push footnote to the bottom */
  margin-bottom: var(--spacing-medium);
  padding: 0 var(--spacing-medium);
  width: 100%; /* Ensure it spans full width */
  box-sizing: border-box;
}

.stop_container {
  text-align: center;
  padding-top: var(--spacing-medium);
}

.timestop {
  text-align: center;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  font-weight: bold;
  border-radius: 5px;
  border: 1px solid var(--accent-yellow);
  color: var(--accent-yellow);
  background-color: var(--background-dark);
  padding: 8px 15px;
  display: inline-block;
}

.timestop:hover {
  color: white;
  background-color: var(--accent-yellow);
}

/*
 * Responsive Adjustments
 * -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  /* Raport items: reduce to 4 per row */
  .raport {
    flex: 1 1 calc(25% - var(--spacing-small) * 2);
    max-width: calc(25% - var(--spacing-small) * 2);
  }
}

@media (max-width: 1024px) {
  .titlu_pag {
    font-size: 2.2em; /* Slightly smaller title */
  }

  /* Raport items: 3 per row */
  .raport {
    flex: 1 1 calc(33.33% - var(--spacing-small) * 2);
    max-width: calc(33.33% - var(--spacing-small) * 2);
  }

  /* Choice items: 2 per row */
  .choice {
    flex: 1 1 calc(50% - var(--spacing-medium) * 2);
    max-width: calc(50% - var(--spacing-medium) * 2);
  }
  .choice button {
    height: 250px; /* Reduced height */
    font-size: 1.8em;
  }
}

@media (max-width: 768px) {
  .titlu_pag {
    font-size: 1.6em;
  }

  /* Raport items: 2 per row */
  .raport {
    flex: 1 1 calc(50% - var(--spacing-xs) * 2); /* Smaller gap on mobile */
    max-width: calc(50% - var(--spacing-xs) * 2);
    margin: var(--spacing-xs); /* Smaller margins */
  }

  .poza_raport {
    height: 130px; /* Further reduced height */
    font-size: 0.9em;
  }

  .poza_raport b {
    font-size: 0.9em;
  }
  .poza_raport p {
    font-size: 0.65em;
  }

  /* Choice items: 1 per row */
  .choice {
    flex: 1 1 calc(100% - var(--spacing-medium) * 2); /* Full width */
    max-width: calc(100% - var(--spacing-medium) * 2);
    margin: var(--spacing-medium) auto; /* Center individual choice items */
  }

  .choice button {
    height: 200px; /* Reduced height for mobile */
    font-size: 1.6em;
  }

  .choice_raport b {
    font-size: 1em;
  }
  .choice_raport p {
    font-size: 0.7em;
  }

  .login-logo {
    width: 90px;
  }
  h2 {
    font-size: 1.4em;
  }
  .login-btn {
    padding: 10px 20px;
    font-size: 1em;
  }
  .favorite-icon {
    font-size: 1.8em; /* Make icon larger on medium screens */
    top: var(--spacing-small); /* Push it slightly further from top edge */
    right: var(--spacing-small); /* Push it slightly further from right edge */
    padding: var(--spacing-xs); /* Increase padding for even larger touch target */
    background-color: rgba(27, 27, 27, 0.5); /* Semi-transparent background for better visibility/touch */
    border-radius: var(--border-radius-default); /* More rounded/pill shape */
  }

  .favorite-icon.favorited {
    background-color: rgba(242, 200, 17, 0.3); /* Lighter background when favorited */
  }
}

@media (max-width: 480px) {
  .titlu_pag {
    font-size: 1.3em;
  }

  /* Raport items: 1 per row */
  .raport {
    flex: 1 1 calc(100% - var(--spacing-xs) * 2);
    max-width: calc(100% - var(--spacing-xs) * 2);
    margin: var(--spacing-xs) auto; /* Center individual items */
  }

  .poza_raport {
    height: 100px; /* Even smaller height */
    font-size: 0.8em;
  }

  .poza_raport b {
    font-size: 0.8em;
  }
  .poza_raport p {
    font-size: 0.6em;
  }

  .choice button {
    height: 160px; /* Smaller height for tiny screens */
    font-size: 1.3em;
  }

  .logo_otter {
    width: 70px;
  }

  .login-logo {
    width: 70px;
  }
  h2 {
    font-size: 1.2em;
  }
  .login-btn {
    padding: 8px 16px;
    font-size: 0.9em;
  }
  .favorite-icon {
    font-size: 2em; /* Even larger icon on small mobile screens */
    padding: var(--spacing-small); /* Maximum padding for easiest touch */
  }
}

/*
 * Department Selection Popup Styles
 * -------------------------------------------------------------------------- */
.department-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent overlay */
  display: flex; /* Acum e întotdeauna flex, dar .hidden îl ascunde */
  justify-content: center;
  align-items: center;
  z-index: 10000; /* Highest z-index */

  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s ease, visibility 0.3s ease,
    transform 0.3s ease; /* Adăugat transform la tranziție */
}

/* Clasa "hidden" aplicată overlay-ului pentru a-l ascunde cu tranziție */
.department-popup-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-20px); /* Animație la ieșire */
}

.department-popup-content {
  background-color: var(--panel-dark);
  border: 2px solid var(--accent-yellow);
  border-radius: var(--border-radius-default);
  padding: var(--spacing-large);
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);

  /* Starea inițială și finală a conținutului, corelată cu overlay-ul */
  transition: none; /* Anulăm tranziția direct pe content, e gestionată de overlay */
}

.department-popup-content h2 {
  color: white;
  margin-bottom: var(--spacing-medium);
  font-size: 1.8em;
}

.department-popup-content p {
  color: var(--text-light);
  margin-bottom: var(--spacing-medium);
  font-size: 1.1em;
}

.department-buttons {
  display: flex;
  flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
  justify-content: center;
  gap: var(--spacing-small); /* Space between buttons */
  margin-bottom: var(--spacing-medium);
  /* Adăugăm un padding lateral pentru a preveni butoanele să atingă marginile */
  padding: 0 var(--spacing-xs);
}

.dept-btn {
  background-color: var(--button-default-bg);
  color: var(--button-default-text);
  border: 1px solid var(--text-muted);
  border-radius: var(--border-radius-small);
  padding: 12px 25px;
  font-size: 1.1em;
  font-weight: bold;
  flex: 1 1 auto; /* Allow buttons to grow, but fit in row */
  min-width: 120px; /* Minimum width for buttons - ajustăm în media queries */
  box-sizing: border-box; /* Asigură că padding și border sunt incluse în lățime */
}

.dept-btn:hover {
  background-color: var(--accent-yellow);
  color: var(--background-dark);
  border-color: var(--accent-yellow-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.small-text {
  font-size: 0.9em;
  color: var(--text-muted);
}

/* --- NEW STYLES FOR REPORTS/FAVORITES/SEARCH --- */

/* Search Container styles */
.search-container {
  text-align: center;
  margin: var(--spacing-medium) 0; /* Use CSS variable for consistency */
}

#searchInput {
  width: 50%;
  padding: var(--spacing-xs); /* Use CSS variable */
  border: 2px solid var(--accent-yellow); /* Consistent border color */
  border-radius: var(--border-radius-small); /* Consistent border radius */
  font-size: 1em;
  background-color: var(--panel-dark); /* Dark background for input */
  color: var(--text-light); /* Light text color */
}

#searchInput::placeholder {
  color: var(--text-muted); /* Placeholder text color */
}

/* Message for no search results */
#noReportsMessage {
  text-align: center;
  margin-top: var(--spacing-large);
  font-size: 1.2em;
  color: var(--text-light);
  display: none; /* Hidden by default */
}

/* Message for no favorites */
#noFavoritesMessage {
  text-align: center;
  margin-top: var(--spacing-large);
  font-size: 1.2em;
  color: var(--text-light);
  display: none; /* Hidden by default */
}

/* NEW CSS CLASS TO HIDE THE CONTAINER WITHOUT BREAKING ITS LAYOUT */
.hidden-container {
  display: none !important; /* Use !important to ensure it overrides existing display properties */
}

/* Favorite icon styling (Default for larger screens) */
.favorite-icon {
  position: absolute;
  top: var(--spacing-xs); /* 10px */
  right: var(--spacing-xs); /* 10px */
  font-size: 1.5em; /* Default size */
  cursor: pointer;
  color: var(--text-muted); /* Default color for unfavorited */
  z-index: 10;
  transition: color var(--transition-speed);
  /* NEW: Add padding to increase touch target without changing icon visual size */
  padding: var(--spacing-xxs); /* 5px padding */
  border-radius: var(--border-radius-small); /* Slightly rounded corners */
}

.favorite-icon.favorited {
  color: var(--accent-yellow); /* Color when favorited */
}

.favorite-icon:hover {
  color: var(--accent-yellow-light); /* Hover effect for star */
  transform: scale(1.1);
}

/* Favorites controls button */
.favorite-controls {
  text-align: center;
  margin: var(--spacing-medium) 0 var(--spacing-large) 0;
}

.favorite-controls button {
  background-color: var(--google-blue); /* A nice blue for the toggle */
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: var(--border-radius-small);
  cursor: pointer;
  font-size: 1em;
  transition: background-color var(--transition-speed),
    transform var(--transition-speed);
}

.favorite-controls button:hover {
  background-color: var(--google-blue-hover);
  transform: translateY(-2px);
}


/* DUPA MODIFICAREA CU STOCAREA RAPOARTELOR IN FIRESTORE */
/* ... (toate stilurile tale existente) ... */

/* --- Stiluri Gruparea pe Categorii --- */
.category-header {
  width: 100%;
  padding: var(--spacing-small) var(--spacing-medium);
  margin-top: var(--spacing-large);
  border-bottom: 2px solid var(--accent-yellow);
  text-align: left;
}

.category-header:first-of-type {
    margin-top: var(--spacing-small);
}

.category-header h2 {
  margin: 0;
  font-size: 1.8em;
  color: white;
}

.category-reports-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  width: 100%;
}

.container {
    justify-content: flex-start;
    align-items: flex-start;
    padding-left: 0;
    padding-right: 0;
}

/* Spinner intern pentru încărcarea rapoartelor */
.spinner-inside {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid var(--accent-yellow);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  /* Margin este setat inline în HTML acum */
}

/* Keyframes pentru animația spin (dacă nu există deja) */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .category-header h2 {
        font-size: 1.5em;
    }
    .container {
        padding-left: var(--spacing-xs);
        padding-right: var(--spacing-xs);
    }
}
/* --- Sfârșit Stiluri Categorii --- */
