/* --- Variable Definitions --- */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --surface: #ffffff;
  --bg-main: #f8fafc;
  --drawer-bg: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --error: #ef4444;
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --radius-xl: 24px;
  --radius-md: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Plus Jakarta Sans", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
}

/* --- Layout Core --- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Drawer */
.drawer {
  width: 280px;
  background: var(--drawer-bg);
  padding: 2rem 1.2rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-header {
  display: flex;
  align-items: center;
  margin-bottom: 2.5rem;
}
.logo-box {
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 8px;
  display: flex;
}
.logo-text {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
  margin-left: 10px;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem 0.5rem;
  letter-spacing: 0.05rem;
}

.nav-item {
  border: none;
  background: transparent;
  padding: 12px 16px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-radius: var(--radius-md);
  font-weight: 700;
  color: var(--text-muted);
  transition: 0.2s;
  margin-bottom: 4px;
}
.nav-item:hover {
  background: #e2e8f0;
  color: var(--text-main);
}
.nav-item.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-md);
}

.drawer-footer {
  margin-top: auto;
}
.stat-card {
  background: white;
  padding: 1.2rem;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}
.stat-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 8px;
  font-weight: 600;
}
.progress-bar-bg {
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: 0.6s ease;
}

/* Main Workspace */
.main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.top-header {
  height: 72px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: white;
}

.search-bar {
  background: #f1f5f9;
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  width: 320px;
  transition: 0.3s;
}
.search-bar:focus-within {
  background: white;
  box-shadow: 0 0 0 2px var(--primary);
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  font-family: inherit;
  outline: none;
}
.shortcut-hint {
  background: #cbd5e1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  color: #475569;
}

.fab-add {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
  transition: 0.2s;
}
.fab-add:hover {
  background: var(--primary-dark);
  transform: scale(1.02);
}

.scroll-container {
  padding: 2.5rem;
  overflow-y: auto;
  flex: 1;
}
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* --- Header & Search Updates --- */
.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1; /* Allows this side to grow */
}

.search-bar {
    background: #f1f5f9;
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    width: 100%;
    max-width: 500px; /* Search bar is now responsive and larger */
    transition: all 0.3s ease;
}

.search-bar:focus-within {
    background: white;
    box-shadow: 0 0 0 2px var(--primary);
    max-width: 550px; /* Slight expansion effect on focus */
}

/* --- Visibility Logic: Hide Mobile elements on Web --- */
.menu-toggle, 
.mobile-close-btn {
    display: none !important; 
}


/* Cards Styling */
.task-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: 0.3s;
}
.task-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}
.task-card.done {
  opacity: 0.6;
  background: #f8fafc;
}
.task-card.done h3 {
  text-decoration: line-through;
}

.tag-priority {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  display: inline-block;
}
.High {
  background: #fee2e2;
  color: #8b1414;
}
.Medium {
  background: #fef3c7;
  color: #aa490c;
}
.Low {
  background: #dcfce7;
  color: #177039;
}

/* --- Modal Logic --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal-box {
  background: white;
  width: 100%;
  max-width: 540px;
  border-radius: 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: popIn 0.3s ease;
  overflow: hidden;
}

@keyframes popIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-view,
.modal-form {
  padding: 2rem;
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.close-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  padding: 8px;
  border-radius: 50%;
  transition: 0.2s;
}
.close-icon:hover {
  background-color: #f1f5f9;
  color: var(--error);
}

/* Mode 1: View Content Styling */
.view-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 1.2rem;
  letter-spacing: -0.02em;
}

.view-meta-bar {
  display: flex;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  gap: 16px;
  margin-bottom: 1.5rem;
}
.meta-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.meta-item .material-icons-round {
  color: var(--primary);
  background: white;
  padding: 8px;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 20px;
}
.meta-text {
  display: flex;
  flex-direction: column;
}
.meta-text label {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--text-muted);
}
.meta-text span {
  font-size: 0.9rem;
  font-weight: 700;
}
.meta-separator {
  width: 1px;
  background: var(--border);
  height: 32px;
}

.view-content-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.view-description-box {
  background: white;
  border: 1px solid var(--border);
  padding: 1.25rem;
  border-radius: 16px;
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100px;
  white-space: pre-wrap;
}

/* Mode 2: Form Content Styling */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  padding-left: 4px;
}
.field input,
.field select,
.field textarea {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
  transition: 0.2s;
  outline: none;
}
.field input:focus {
  border-color: var(--primary);
  background: white;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.type-selector {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}
.type-selector input {
  display: none;
}
.type-selector label {
  flex: 1;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: 0.2s;
}
.type-selector input:checked + label {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-md);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #f1f5f9;
}
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-secondary-flat {
  background: #f1f5f9;
  color: var(--text-muted);
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-danger-text {
  color: var(--error);
  background: transparent;
  border: none;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-radius: 10px;
}
.btn-danger-text:hover {
  background: #fef2f2;
}

/* Global Utilities */
.hidden {
  display: none !important;
}
.empty-ui {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 5rem 0;
  text-align: center;
  color: var(--text-muted);
}
.toast-popup {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
  z-index: 3000;
}
.toast-popup.show {
  opacity: 1;
  visibility: visible;
  bottom: 40px;
}

/* Responsive */
@media (max-width: 1024px) {
  .drawer {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    z-index: 1000;
  }
  .drawer.active {
    left: 0;
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
  }
  .sidebar-overlay.active {
    display: block;
  }
  .menu-toggle {
    display: flex;
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    margin-right: 1rem;
  }
}
@media (max-width: 640px) {
  .task-grid {
    grid-template-columns: 1fr;
  }
  .fab-text,
  .shortcut-hint,
  .date-widget {
    display: none;
  }
}

/* ============================================================
   RESPONSIVE UPDATES
   ============================================================ */

/* TABLET & MOBILE VIEW (Below 1024px) */
@media (max-width: 1024px) {
    /* Show the toggle button ONLY on mobile/tablet */
    .menu-toggle {
        display: flex !important;
        background: #f1f5f9;
        border: none;
        padding: 8px;
        border-radius: 8px;
        color: var(--primary);
        cursor: pointer;
    }

    /* Show the close button ONLY inside the mobile sidebar */
    .mobile-close-btn {
        display: flex !important;
        position: absolute;
        right: 15px;
        top: 35px;
        background: transparent;
        border: none;
        color: var(--primary-dark);
        padding: 4px;
    }

    .drawer {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 2000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .drawer.active {
        transform: translateX(0);
    }

    .search-bar {
        max-width: 100%; /* Full width on smaller mobile screens */
    }
}

/* SMALL MOBILE (Below 640px) */
@media (max-width: 640px) {
    .header-right .date-widget, 
    .shortcut-hint {
        display: none; /* Hide date and '/' hint on small phones to save space */
    }
    
    .top-header {
        padding: 0 1rem;
    }
}
