/* Galaxy background */
    html { direction: rtl; } /* Added RTL direction */
    body, html {
      height: 100%;
      margin: 0;
      padding: 0;
      font-family: 'Vazirmatn', Arial, sans-serif; /* Already using a Farsi font */
      min-height: 100vh;
      position: relative;
      overflow-x: hidden;
    }

    .galaxy-bg {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      width: 100vw;
      height: 100vh;
      z-index: 0;
      background: radial-gradient(ellipse at 70% 20%, #fff8, transparent 60%),
                  radial-gradient(ellipse at 20% 80%, #fff4, transparent 60%),
                  linear-gradient(120deg, #0f2027 0%, #2c5364 100%);
      background-image:
        url('https://mczxodbdeyozrjpxjxgr.supabase.co/storage/v1/object/public/background//nasa-rTZW4f02zY8-unsplash.jpg'),
        radial-gradient(ellipse at 70% 20%, #fff8, transparent 60%),
        radial-gradient(ellipse at 20% 80%, #fff4, transparent 60%),
        linear-gradient(120deg, #0f2027 0%, #2c5364 100%);
      background-size: cover, cover, cover, cover;
      background-position: center center, center center, center center, center center;
      filter: brightness(0.85) blur(0px);
      pointer-events: none;
    }

    .container {
      position: relative;
      z-index: 1;
      max-width: 950px;
      margin: 40px auto;
      background: rgba(255,255,255,0.13);
      border-radius: 24px;
      box-shadow: 0 8px 32px 0 rgba(31,38,135,0.37);
      backdrop-filter: blur(16px) saturate(180%);
      -webkit-backdrop-filter: blur(16px) saturate(180%);
      border: 1.5px solid rgba(255,255,255,0.18);
      padding: 36px 24px 24px 24px;
      box-sizing: border-box;
    }

    h1 {
      text-align: center;
      margin-bottom: 24px;
      color: #fff;
      letter-spacing: 2px;
      font-weight: 700;
      text-shadow: 0 2px 12px #0008;
      font-size: 2.2rem;
    }

    #progress-bar-container {
      width: 100%;
      background: rgba(255,255,255,0.10);
      border-radius: 12px;
      margin-bottom: 24px;
      position: relative;
      height: 36px;
      display: flex;
      align-items: center;
      box-shadow: 0 2px 8px 0 rgba(31,38,135,0.10);
      overflow: hidden;
      border: 1px solid rgba(255,255,255,0.18);
      backdrop-filter: blur(8px);
    }

    #progress-bar {
      height: 100%;
      background: linear-gradient(90deg, #2196f3cc, #4caf50cc 80%); /* Reversed gradient for RTL */
      border-radius: 0 12px 12px 0; /* Adjusted border-radius for RTL */
      transition: width 0.3s;
      min-width: 0;
      box-shadow: 0 2px 8px #2196f366;
    }

    #progress-text {
      position: absolute;
      width: 100%;
      text-align: center;
      color: #fff;
      font-weight: bold;
      z-index: 1;
      font-size: 1.08rem;
      text-shadow: 0 1px 6px #0008;
      letter-spacing: 1px;
      /* Ensure text aligns correctly within the bar */
      left: auto;
      right: 0;
    }

    #board {
      display: flex;
      gap: 24px;
      justify-content: space-between;
      margin-bottom: 24px;
      flex-wrap: wrap;
      /* Ensure columns flow RTL */
      flex-direction: row-reverse;
    }

    /* Style for the new Routine column */
    .column[data-status='routine'] {
      background: rgba(156, 39, 176, 0.18); /* Purple-ish background */
      border: 1.5px solid rgba(186, 104, 200, 0.25);
    }
    .column[data-status='routine'] h2 {
      color: #ce93d8; /* Lighter purple text */
    }


    .column {
      background: rgba(255,255,255,0.18);
      border-radius: 18px;
      flex: 1 1 260px;
      min-width: 220px;
      padding: 18px 12px 12px 12px;
      box-shadow: 0 2px 12px 0 rgba(31,38,135,0.10);
      display: flex;
      flex-direction: column;
      max-height: 520px;
      overflow-y: auto;
      border: 1.5px solid rgba(255,255,255,0.18);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      margin-bottom: 8px;
      transition: box-shadow 0.2s, border 0.2s;
    }

    .column h2 {
      text-align: center;
      margin: 0 0 14px 0;
      font-size: 1.13rem;
      color: #fff;
      font-weight: 600;
      letter-spacing: 1px;
      text-shadow: 0 1px 6px #0006;
    }

    .task-list {
      flex: 1;
      min-height: 40px;
    }

    /* Task Styles */
    .task {
      position: relative;
      background: rgba(255,255,255,0.22);
      border-radius: 10px;
      margin-bottom: 12px;
      padding: 12px 14px;
      box-shadow: 0 2px 8px rgba(31,38,135,0.10);
      cursor: grab;
      font-size: 1.04rem;
      display: flex;
      flex-direction: column;
      transition: box-shadow 0.2s, background 0.2s;
      color: #fff;
      font-weight: 500;
      border: 1px solid rgba(255,255,255,0.18);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      user-select: none;
    }

    .task .timer,
    .task .duration {
      font-size: 0.85rem;
      color: #ffd700;
      margin-right: 10px; /* Changed margin-left to margin-right */
      margin-left: 0;
      font-weight: 400;
      letter-spacing: 0.5px;
      text-shadow: 0 1px 4px #000a;
      direction: ltr;
    }

    .task .duration {
      color: #90ee90;
    }

    .task.dragging {
      opacity: 0.55;
      box-shadow: 0 6px 24px 0 #2196f3aa;
      background: rgba(33,150,243,0.18);
    }

    .task.invisible {
      /* Remove this style */
    }

    .drag-handle {
      /* Remove this style */
    }

    .task .delete-btn {
      background: none;
      border: none;
      color: #ff5252;
      font-size: 1.2rem;
      cursor: pointer;
      margin-right: 12px; /* Changed margin-left to margin-right */
      margin-left: 0;
      padding: 0;
      transition: color 0.2s;
      filter: drop-shadow(0 1px 2px #0008);
    }

    /* Container for top-right controls (edit button, or delete for non-done tasks) */
    .task-controls {
      position: absolute;
      top: 8px; /* Adjust as needed */
      left: 10px; /* Position top-left for RTL */
      display: flex;
      align-items: center;
      gap: 8px;
      z-index: 2; /* Ensure controls are above other content */
    }

    /* Edit Description Button */
    .edit-desc-btn {
      background: none;
      border: none;
      color: #90caf9; /* Light blue */
      font-size: 1.1rem; /* Slightly smaller than delete */
      cursor: pointer;
      padding: 0;
      transition: color 0.2s, text-shadow 0.2s;
      filter: drop-shadow(0 1px 2px #0008);
    }
    .edit-desc-btn:hover {
      color: #e3f2fd; /* Lighter blue on hover */
      text-shadow: 0 0 8px #2196f3aa;
    }


    .task .delete-btn:hover {
      color: #fff;
      text-shadow: 0 0 8px #ff5252cc;
    }

    /* Specific style for delete button when at the bottom of a 'done' task */
    .column[data-status='done'] > .task-list > .task > .delete-btn {
        position: relative; /* Reset position from absolute if needed */
        align-self: flex-end; /* Align to the bottom right (flex-end for RTL) */
        margin-top: 8px; /* Space above the button */
        margin-left: 5px; /* Small margin from the edge */
        margin-right: auto; /* Push to the right */
    }


    .column.drag-over {
      background: rgba(33,150,243,0.18);
      border: 2.5px dashed #90caf9;
      box-shadow: 0 0 16px #2196f3cc;
    }

    /* Task Description Styles */
    .task-description-container {
      margin-top: 8px; /* Space below title/timer */
      padding-top: 8px; /* Space above description */
      border-top: 1px solid rgba(255, 255, 255, 0.1); /* Separator line */
      width: 100%; /* Take full width */
      /* Ensure description container doesn't overlap absolute controls */
      padding-top: 28px; /* Add padding to top to avoid overlap with controls */
      margin-top: 0; /* Reset margin-top */
    }

    .task-description {
      font-size: 0.9rem; /* Smaller font size */
      color: rgba(255, 255, 255, 0.85); /* Slightly dimmer text */
      line-height: 1.4;
      margin: 0;
      word-wrap: break-word;
    }
    .task-description i { /* Style for "No description" text */
       opacity: 0.7;
    }


    #add-task-form {
      display: flex;
      gap: 12px;
      margin-top: 10px;
      justify-content: center;
      background: rgba(255,255,255,0.10);
      border-radius: 10px;
      padding: 10px 12px;
      box-shadow: 0 1px 6px #0002;
      border: 1px solid rgba(255,255,255,0.13);
      backdrop-filter: blur(6px);
      /* Add space for schedule time if present */
      padding-bottom: 25px; /* Ensure space for schedule time */
    }
    
    /* New container for schedule time */
    .schedule-container {
      display: block;
      width: 100%;
      text-align: center;
      margin-top: 8px; /* Space after delete button */
    }
    
    .task .schedule-time {
      /* position: absolute; Removed */
      /* bottom: 6px; Removed */
      /* left: 50%; Removed */
      /* transform: translateX(-50%); Removed */
      /* right: auto; Removed */
      display: inline-block;
      font-size: 0.8rem;
      color: #eee;
      opacity: 0.85; /* Slightly more visible */
      background: rgba(0,0,0,0.2); /* Subtle background */
      padding: 1px 4px;
      border-radius: 3px;
    }


    #add-task-form input[type="text"] { /* Target only text input */
      flex: 1;
      padding: 10px 12px;
      border-radius: 7px;
      border: 1px solid rgba(255,255,255,0.18);
      font-size: 1.04rem;
      background: rgba(255,255,255,0.18);
      color: #fff;
      outline: none;
      transition: border 0.2s, background 0.2s;
      box-shadow: 0 1px 4px #0002;
      backdrop-filter: blur(4px);
    }

    /* Styles for routine options in the form */
    .routine-options {
      display: flex;
      align-items: center;
      gap: 8px;
      margin: 0 10px; /* Add some margin */
      position: relative; /* Needed for absolute positioning of custom checkbox */
    }

    /* Custom Checkbox Styling */
    .routine-options label[for="new-task-is-routine"] { /* Target the specific label */
      color: #fff;
      font-size: 0.95rem;
      cursor: pointer;
      padding-right: 24px; /* Space for custom checkbox */
      position: relative;
      user-select: none; /* Prevent text selection */
      display: inline-block; /* Ensure proper layout */
      line-height: 18px; /* Align text vertically */
    }
    .routine-options label[for="new-task-is-routine"]::before { /* The box */
      content: '';
      position: absolute;
      right: 0; /* Position for RTL */
      top: 0;
      width: 16px;
      height: 16px;
      border: 1.5px solid rgba(255, 255, 255, 0.6);
      background: rgba(255, 255, 255, 0.1);
      border-radius: 4px;
      transition: background 0.2s, border-color 0.2s;
    }
    .routine-options label[for="new-task-is-routine"]::after { /* The checkmark */
      content: '✔';
      position: absolute;
      right: 3px; /* Position for RTL */
      top: -1px;
      font-size: 14px;
      color: #fff;
      opacity: 0;
      transition: opacity 0.2s;
    }
    .routine-options input[type="checkbox"]#new-task-is-routine { /* Hide default checkbox */
      opacity: 0;
      position: absolute;
      width: 0;
      height: 0;
    }
    .routine-options input[type="checkbox"]#new-task-is-routine:checked + label[for="new-task-is-routine"]::before {
      background: #ab47bc; /* Purple background when checked */
      border-color: #ab47bc;
    }
     .routine-options input[type="checkbox"]#new-task-is-routine:checked + label[for="new-task-is-routine"]::after {
      opacity: 1; /* Show checkmark */
    }
    /* --- End Custom Checkbox --- */

    .routine-options input[type="time"] {
      padding: 6px 8px; /* Smaller padding */
      border-radius: 5px;
      border: 1px solid rgba(255,255,255,0.18);
      font-size: 0.95rem;
      background: rgba(255,255,255,0.18);
      color: #fff;
      outline: none;
      transition: border 0.2s, background 0.2s, opacity 0.3s, visibility 0.3s;
      box-shadow: 0 1px 4px #0002;
      backdrop-filter: blur(4px);
      max-width: 100px; /* Limit width */
    }
    .hidden-time-input {
      opacity: 0;
      visibility: hidden;
      width: 0; /* Collapse width when hidden */
      padding: 0;
      border: none;
      margin: 0;
    }


    #add-task-form input[type="text"]::placeholder { /* Target only text input */
      color: #e3e3e3;
      opacity: 0.8;
      font-weight: 400;
    }

    #add-task-form input:focus {
      border: 1.5px solid #2196f3;
      background: rgba(255,255,255,0.28);
    }
    .routine-options input[type="time"]:focus {
       border: 1.5px solid #ab47bc; /* Purple focus */
       background: rgba(255,255,255,0.28);
    }


    #add-task-form button {
      padding: 10px 22px;
      border-radius: 7px;
      border: none;
      background: linear-gradient(90deg, #4caf50 0%, #2196f3 40%); /* Reversed gradient for RTL */
      color: #fff;
      font-size: 1.04rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.2s, box-shadow 0.2s;
      box-shadow: 0 1px 4px #2196f366;
      letter-spacing: 1px;
    }

    #add-task-form button:hover {
      background: linear-gradient(90deg, #388e3c 0%, #1769aa 40%); /* Reversed gradient for RTL */
      box-shadow: 0 2px 8px #2196f399;
    }


/* --- Notes Section Styles --- */
#notes-section {
  margin-top: 30px; /* Space above the notes section */
  margin-bottom: 24px;
  padding: 20px 18px;
  background: rgba(255,255,255,0.10);
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(31,38,135,0.15);
  border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#notes-section h2 {
  text-align: center;
  margin: 0 0 18px 0;
  font-size: 1.2rem; /* Slightly larger than column headers */
  color: #fff;
  font-weight: 600;
  letter-spacing: 1px;
  text-shadow: 0 1px 6px #0006;
}

#notes-list {
  max-height: 300px; /* Limit height and allow scrolling */
  overflow-y: auto;
  margin-bottom: 18px; /* Space between list and form */
  padding-right: 10px; /* Padding for scrollbar */
}

.note-item {
  background: rgba(255,255,255,0.18);
  border-radius: 10px;
  margin-bottom: 12px;
  padding: 12px 16px; /* Standard padding */
  padding-left: 40px; /* Space for delete button */
  box-shadow: 0 2px 8px rgba(31,38,135,0.10);
  position: relative; /* For positioning delete button */
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.note-item p {
  margin: 0;
  word-wrap: break-word; /* Wrap long words */
  line-height: 1.5; /* Improve readability */
  font-size: 1.02rem;
  font-weight: 400;
}

.delete-note-btn {
  position: absolute;
  top: 50%;
  left: 10px; /* Position on the left for RTL */
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #ff7b7b; /* Lighter red */
  font-size: 1.8rem; /* Larger click target */
  font-weight: bold;
  cursor: pointer;
  padding: 0 5px;
  line-height: 1;
  transition: color 0.2s, text-shadow 0.2s;
  filter: drop-shadow(0 1px 2px #0008);
}

.delete-note-btn:hover {
  color: #ff3d3d; /* Brighter red on hover */
  text-shadow: 0 0 6px #ff5252aa;
}

#add-note-form {
  display: flex;
  gap: 12px;
  align-items: flex-start; /* Align items to the top */
}

#add-note-form textarea {
  flex: 1; /* Take available space */
  min-height: 60px; /* Minimum height */
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 1.04rem;
  background: rgba(255,255,255,0.18);
  color: #fff;
  outline: none;
  transition: border 0.2s, background 0.2s;
  box-shadow: 0 1px 4px #0002;
  backdrop-filter: blur(4px);
  resize: vertical; /* Allow vertical resize */
  font-family: inherit; /* Use the body font */
}

#add-note-form textarea::placeholder {
  color: #e3e3e3;
  opacity: 0.8;
  font-weight: 400;
}

#add-note-form textarea:focus {
  border: 1.5px solid #2196f3;
  background: rgba(255,255,255,0.28);
}

#add-note-form button {
  /* Reuse styles from add task button */
  padding: 10px 22px;
  border-radius: 7px;
  border: none;
  background: linear-gradient(90deg, #4caf50 0%, #2196f3 40%); /* Reversed gradient for RTL */
  color: #fff;
  font-size: 1.04rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px #2196f366;
  letter-spacing: 1px;
  height: fit-content; /* Adjust height to content */
  align-self: flex-end; /* Align button to bottom of flex container if textarea grows */
}

#add-note-form button:hover {
  background: linear-gradient(90deg, #388e3c 0%, #1769aa 40%); /* Reversed gradient for RTL */
  box-shadow: 0 2px 8px #2196f399;
}

.no-notes {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  padding: 20px;
  font-style: italic;
}
/* --- End Notes Section Styles --- */


/* Button container styles */
.button-container {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

/* Common button styles */
#export-excel-btn,
.external-link-btn {
  padding: 10px 22px;
  border-radius: 7px;
  border: none;
  background: linear-gradient(90deg, #4caf50 0%, #2196f3 40%);
  color: #fff;
  font-size: 1.04rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px #2196f366;
  letter-spacing: 1px;
  min-width: 160px; /* Set minimum width for both buttons */
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

#export-excel-btn:hover,
.external-link-btn:hover {
  background: linear-gradient(90deg, #388e3c 0%, #1769aa 40%);
  box-shadow: 0 2px 8px #2196f399;
  color: #fff;
  text-decoration: none;
}

/* Remove the old individual button styles */
#export-excel-btn {
  margin: 0; /* Remove the auto margins */
}

@media (max-width: 800px) {
      #board {
        flex-direction: column;
        gap: 18px;
      }
      .column {
        max-height: none;
      }
      /* Responsive styles for Add Task Form */
      #add-task-form {
        flex-direction: column; /* Stack elements vertically */
        align-items: stretch; /* Stretch items to full width */
        padding-bottom: 15px; /* Adjust padding */
      }
      #add-task-form input[type="text"],
      #add-task-form .routine-options,
      #add-task-form button {
        margin-bottom: 10px; /* Add space between stacked items */
      }
      #add-task-form .routine-options {
        justify-content: center; /* Center routine options */
        margin: 0 0 10px 0; /* Adjust margin */
      }
      #add-task-form button {
        margin-bottom: 0; /* No bottom margin on last item */
      }
    }

/* Remove the new styles we added */
.task:hover {
  /* Remove these styles */
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
