:root {
  /* Define some CSS variables for a clean, iOS-like look */
  --ios-blue: #007aff;
  --ios-red: #ff3b30;
  --ios-green: #34c759;
  --ios-light-gray: #f2f2f7;
  --ios-medium-gray: #c7c7cc;
  --ios-dark-gray: #8e8e93;
  --text-color-dark: #1c1c1e;
  --text-color-light: #ffffff;
  --card-background: #ffffff;
  --border-color: #e0e0e0;
}

/* Global reset for box-sizing */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Base Body Styling */
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--ios-light-gray); /* This will be the background outside the app frame */
  color: var(--text-color-dark);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  width: 100%;
  box-sizing: border-box;
}

/* App Container Styling - Default for Desktop/Tablet (Framed Look) */
.app-container {
  width: 100%;
  max-width: 750px; /* Adjust this value to make the app wider on desktop */
  background-color: var(--card-background);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 40px);
  position: relative;
  margin: 20px auto;
  flex-grow: 1;
  flex-shrink: 0;
  flex-basis: auto;
}

/* Media Query for Mobile (Full-width App) */
@media (max-width: 767px) {
  body {
    background-color: var(--card-background); /* Match app background on mobile for seamless look */
  }
  .app-container {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    min-height: 100vh;
  }

  /* Adjust internal paddings for app sections when full-width on mobile */
  .app-header,
  .counters-list,
  .bottom-sticky-wrapper .total-footer,
  .bottom-sticky-wrapper .ad-placeholder {
    padding-left: 15px;
    padding-right: 15px;
  }
}

/* App Header Styling */
.app-header {
  background-color: var(--card-background);
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* NEW: Logo Styling */
.app-logo {
  height: 40px; /* Adjust as needed */
  max-width: 150px; /* Adjust as needed, prevents logo from being too wide */
  object-fit: contain; /* Ensures the entire image is visible within its bounds */
}

/* OLD: Removed h1 styling as it's no longer there
.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--text-color-dark);
}
*/

.header-buttons {
  display: flex;
  gap: 8px;
}

.add-new-counter-button {
  background-color: var(--ios-blue);
  color: var(--text-color-light);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.add-new-counter-button:active {
  background-color: #0056b3;
}

/* Counters List Area */
.counters-list {
  flex-grow: 1;
  padding: 10px;
  padding-bottom: calc(10px + 90px); /* Space for the fixed total + ad area */
  background-color: var(--ios-light-gray);
  overflow-y: auto;
}

/* Individual Counter Card Styling */
.counter-card {
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  transition: padding 0.3s ease, margin-bottom 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.counter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  gap: 8px;
  transition: margin-bottom 0.3s ease;
  position: relative;
}

.counter-name-input {
  flex-grow: 1;
  border: 1px solid;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 14px;
  font-weight: 500;
  -webkit-appearance: none;
  appearance: none;
  transition: padding 0.3s ease, font-size 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.counter-name-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.counter-name-input:focus {
  outline: none;
  border-color: var(--ios-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

/* Options Menu Icon (Hamburger) */
.options-menu-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  font-size: 20px;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
  transition: color 0.2s ease, transform 0.1s ease;
  margin-left: 5px;
}

.options-menu-icon:active {
  transform: scale(0.9);
}

/* Main Options Menu dropdown */
.options-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1001;
  background-color: var(--card-background);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  padding: 8px;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform-origin: top right;
  opacity: 1;
  transform: scale(1);
  min-width: 150px;
  /* Hidden by default, shown by JS */
  display: none;
}

/* Buttons within the options menu */
.options-menu .menu-button {
  background: none;
  border: none;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-color-dark); /* Set to dark, should inherit correctly now */
}

.options-menu .menu-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.options-menu .menu-button:active {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Specific styling for reset and delete buttons within the menu */
.options-menu .delete-button-in-menu {
  color: var(--ios-red);
}

/* Color Picker Menu (sub-menu) */
.color-picker-menu {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1002;
  background-color: var(--card-background);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform-origin: center;
  opacity: 1;
  transform: scale(1);
  /* Hidden by default, shown by JS */
  display: none;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 160px;
  padding: 5px;
}

.color-box {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.color-box:hover {
  transform: scale(1.05);
  border-color: var(--ios-blue);
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.3);
}

/* Counter Display Area (Value and Control Buttons) */
.counter-display-area {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  margin: 10px 0;
  transition: all 0.3s ease;
  padding: 0 5px;
}

.counter-value {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
  min-width: 50px;
  transition: font-size 0.3s ease, margin 0.3s ease, color 0.3s ease;
}

.control-button {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: padding 0.3s ease, font-size 0.3s ease, color 0.3s ease;
  flex-shrink: 0;
  width: 50px;
}

/* Message for no counters */
.no-counters-message {
  text-align: center;
  color: var(--ios-dark-gray);
  font-size: 16px;
  padding: 40px 20px;
}

/* Minimalistic scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--ios-light-gray);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--ios-medium-gray);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ios-dark-gray);
}

/* Wrapper for the entire sticky bottom section (Total + Ad) */
.bottom-sticky-wrapper {
  position: sticky;
  bottom: 0;
  width: 100%;
  background-color: var(--card-background);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
  z-index: 100;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Modified Total Footer Styles (now inside .bottom-sticky-wrapper) */
.total-footer {
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color-dark);
  box-sizing: border-box;
  transition: padding 0.3s ease, font-size 0.3s ease;
}

.total-footer .total-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ios-blue);
  transition: font-size 0.3s ease;
}

/* Advertisement Placeholder Styles */
.ad-placeholder {
  padding: 8px 15px;
  text-align: center;
  font-size: 12px;
  color: var(--ios-dark-gray);
  background-color: var(--ios-light-gray);
  border-top: 1px solid var(--border-color);
  box-sizing: border-box;
}