/* 
  TaskMaster Design System 
  v2.0 - Multi-Theme Support
*/

:root {
  /* --- BASE TOKENS (Shared) --- */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  --rounded-sm: 8px;
  --rounded-md: 16px;
  /* Increased for modern feel */
  --rounded-lg: 24px;
  --rounded-xl: 32px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  /* Softer */
  --shadow-md: 0 8px 16px -4px rgba(0, 0, 0, 0.08);
  /* Deeper lift */
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-active: 0 0 0 3px rgba(99, 102, 241, 0.3);
  /* Focus ring */
}

/* --- THEMES --- */

/* DEFAULT (LIGHT) - Clean & Professional */
[data-theme="light"] {
  --primary-500: #4f46e5;
  /* Indigo 600 - Richer */
  --primary-600: #4338ca;
  /* Indigo 700 */
  --secondary-500: #64748b;
  /* Slate 500 */

  --surface-0: #ffffff;
  --surface-50: #f8fafc;
  /* Slate 50 */
  --surface-100: #f1f5f9;
  /* Slate 100 */
  --surface-200: #e2e8f0;
  /* Slate 200 */
  --surface-300: #cbd5e1;
  /* Slate 300 */

  --text-900: #0f172a;
  /* Slate 900 - High Contrast */
  --text-600: #475569;
  /* Slate 600 - Readable Body */
  --text-400: #94a3b8;
  /* Slate 400 - Muted */

  --success-500: #10b981;
  /* Emerald 500 */
  --warning-500: #f59e0b;
  /* Amber 500 */
  --danger-500: #ef4444;
  /* Red 500 */

  --bg-app: #f3f4f6;
  /* Gray 100 - Slightly warmer app bg */
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --border-color: #e5e7eb;
}

/* DARK - Sleek & Comfortable */
[data-theme="dark"] {
  --primary-500: #818cf8;
  /* Indigo 400 */
  --primary-600: #6366f1;
  /* Indigo 500 */

  --surface-0: #1e293b;
  /* Slate 800 */
  --surface-50: #0f172a;
  /* Slate 900 */
  --surface-100: #1e293b;
  --surface-200: #334155;
  /* Slate 700 */
  --surface-300: #475569;
  /* Slate 600 */

  --text-900: #f8fafc;
  --text-600: #cbd5e1;
  --text-400: #94a3b8;

  --success-500: #34d399;
  --warning-500: #fbbf24;
  --danger-500: #f87171;

  --bg-app: #0b1120;
  /* Very dark blue/gray */
  --bg-sidebar: #111827;
  /* Gray 900 */
  --bg-card: #1f2937;
  /* Gray 800 */
  --border-color: #374151;
}

/* VIBRANT - Sunset Gradients & Glassmorphism */
[data-theme="vibrant"] {
  --primary-500: #ffffff;
  --primary-600: #f1f5f9;

  --surface-0: rgba(255, 255, 255, 0.85);
  /* More opaque for readability */
  --surface-50: transparent;
  --surface-100: rgba(255, 255, 255, 0.5);
  --surface-200: rgba(255, 255, 255, 0.6);

  --text-900: #2e1065;
  /* Deep Purple */
  --text-600: #5b21b6;
  /* Purple 800 */
  --text-400: #7c3aed;
  /* Violet 600 */

  --success-500: #059669;
  --warning-500: #d97706;
  --danger-500: #dc2626;

  --bg-app: linear-gradient(135deg, #a78bfa 0%, #3b82f6 100%);
  /* Modern Purple-Blue Gradient */
  --bg-sidebar: rgba(255, 255, 255, 0.3);
  --bg-card: rgba(255, 255, 255, 0.7);
  --border-color: rgba(255, 255, 255, 0.5);
}

/* --- FOOTER --- */
/* --- FOOTER --- */
.app-footer {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--surface-50);
  border-top: 1px solid var(--border-color);
  border-radius: var(--rounded-md);
  text-align: center;
  color: var(--text-400);
  font-size: 0.9rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* --- RESET & LAYOUT --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.hidden {
  display: none !important;
}

.app-container {
  display: flex;

  body {
    font-family: var(--font-body);
    background: var(--bg-app);
    color: var(--text-900);
    font-size: 16px;
    /* Increased from default */
    line-height: 1.6;
    /* Better readability */
    transition: background 0.3s ease, color 0.3s ease;
    height: 100vh;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    /* Sharper fonts */
  }

  /* --- SCROLLBAR --- */
  ::-webkit-scrollbar {
    width: 8px;
    /* Thinner */
  }

  ::-webkit-scrollbar-track {
    background: transparent;
  }

  ::-webkit-scrollbar-thumb {
    background: var(--surface-300);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--text-400);
  }

  /* --- LAYOUT --- */
  #app {
    display: flex;
    width: 100%;
    height: 100%;
  }

  /* VIBRANT SPECIAL: Glass Background */
  [data-theme="vibrant"] body {
    backdrop-filter: blur(10px);
  }

  /* --- SIDEBAR --- */
  .sidebar {
    width: 280px;
    /* Slightly wider */
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    backdrop-filter: blur(20px);
    /* Enhanced glass effect */
    z-index: 10;
  }

  [data-theme="vibrant"] .sidebar {
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.05);
  }

  .brand {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-500);
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  [data-theme="vibrant"] .brand {
    color: #4c1d95;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--rounded-md);
    color: var(--text-600);
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    font-weight: 500;
  }

  .nav-item:hover {
    background: var(--surface-200);
    color: var(--text-900);
  }

  .nav-item.active {
    background: var(--primary-500);
    color: white;
    box-shadow: var(--shadow-active);
  }

  [data-theme="vibrant"] .nav-item.active {
    background: #6d28d9;
    box-shadow: 0 4px 15px rgba(109, 40, 217, 0.3);
  }

  .user-profile {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
  }

  /* --- MAIN CONTENT --- */
  .main-content {
    flex: 1;
    padding: 1.5rem 3rem;
    /* Reduced top padding */
    overflow-y: auto;
    display: flex;
    /* Ensure flex context */
    flex-direction: column;
    /* Stack top-to-bottom */
    justify-content: flex-start;
    /* Force content to top */
  }

  .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
  }

  h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-900);
    margin-bottom: 0.25rem;
  }

  .subtitle {
    color: var(--text-600);
  }

  /* --- CARDS & PANELS --- */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
  }

  .stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--rounded-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
  }

  .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-900);
    margin: 0.5rem 0;
  }

  .panel {
    background: var(--bg-card);
    border-radius: var(--rounded-lg);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
  }

  /* --- LISTS & ITEMS --- */
  .employee-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
  }

  .employee-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--rounded-lg);
    padding: 1.5rem;
    text-align: center;
    position: relative;
    transition: all 0.2s;
  }

  .employee-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
  }

  .employee-card .avatar {
    margin: 0 auto 1rem;
    width: 64px;
    height: 64px;
    font-size: 1.25rem;
  }

  .task-list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .task-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--rounded-md);
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid transparent;
    transition: all 0.2s;
  }

  .task-item:hover {
    box-shadow: var(--shadow-md);
  }

  .task-item.priority-high {
    border-left-color: var(--danger-500);
  }

  .task-item.priority-medium {
    border-left-color: var(--warning-500);
  }

  .task-item.priority-low {
    border-left-color: var(--success-500);
  }

  /* Task Badges */
  .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 99px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-left: 0.5rem;
  }

  .badge.emergency {
    background: #fee2e2;
    color: #ef4444;
    border: 1px solid #fecaca;
  }

  .badge.flexible {
    background: #e0e7ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
  }

  /* Status Badges */
  .status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
  }

  .status-badge.active {
    background: #dcfce7;
    color: #166534;
  }

  .status-badge.completed {
    background: #dcfce7;
    color: #166534;
  }

  .status-badge.pending {
    background: #fef9c3;
    color: #854d0e;
  }

  .status-badge.acknowledged {
    background: #dbeafe;
    color: #1e40af;
  }

  /* In Dark/Vibrant modes, adjust badge colors slightly if needed, generally hardcoded colors work well enough or need vars */

  .icon-btn:hover {
    background: var(--surface-200);
    color: var(--danger-500);
  }

  input,
  select,
  textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--rounded-md);
    border: 1px solid var(--surface-300);
    background: var(--surface-50);
    color: var(--text-900);
    font-family: inherit;
    margin-top: 0.25rem;
    margin-bottom: 1rem;
  }

  .grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  input:focus,
  select:focus,
  textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  }

  /* --- SEARCH --- */
  .search-container {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: var(--rounded-xl);
    border: 1px solid var(--border-color);
    width: 300px;
    box-shadow: var(--shadow-sm);
  }

  .search-container input {
    border: none;
    background: transparent;
    margin: 0;
    padding: 0.25rem 0.5rem;
    box-shadow: none;
  }

  .search-container i {
    color: var(--text-400);
  }

  /* --- MODALS --- */
  .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: grid;
    place-items: center;
    /* Center horizontally and vertically */
    z-index: 1000;
    backdrop-filter: blur(4px);
    overflow-y: auto;
    /* Enable scrolling for tall modals */
    padding: 1rem;
    /* Prevent touching edges on small screens */
  }

  .modal-overlay.hidden {
    display: none;
  }

  .modal {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--rounded-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    margin: auto;
    /* Important: Centers in grid */
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    /* Prevent modal from being taller than viewport */
    overflow-y: auto;
    /* Scroll internally if still too tall */
  }

  @keyframes modal-pop {
    from {
      opacity: 0;
      transform: scale(0.95) translateY(10px);
    }

    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  /* --- ANIMATIONS --- */
  .fade-in {
    animation: fadeIn 0.4s ease;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(5px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* --- DATA TABLE (Reports) --- */
  .data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
  }

  .data-table th {
    padding: 1rem;
    border-bottom: 2px solid var(--surface-200);
    color: var(--text-600);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--surface-200);
    color: var(--text-900);
  }

  .data-table tr:hover {
    background: var(--surface-50);
  }

  /* --- TOAST --- */
  .toast {
    background: #1e293b;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 99px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
    min-width: 300px;
  }

  .toast.success i {
    color: #4ade80;
  }

  .toast.error i {
    color: #f87171;
  }

  #toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 5000;
  }

  /* --- MESSAGING --- */
  .message-item {
    padding: 1rem;
    border-bottom: 1px solid var(--surface-200);
    cursor: pointer;
    transition: background 0.2s;
  }

  .message-item:hover {
    background: var(--surface-50);
  }

  .message-item.unread {
    background: var(--surface-100);
    border-left: 3px solid var(--primary-500);
  }

  .message-item.active {
    background: var(--surface-200);
  }

  .folder-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--rounded-md);
    color: var(--text-600);
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    font-weight: 500;
  }

  .folder-item:hover {
    background: var(--surface-200);
    color: var(--text-900);
  }

  .folder-item.active {
    background: var(--surface-200);
    color: var(--primary-500);
    font-weight: 700;
  }

  .message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
  }

  .sender-name {
    font-weight: 600;
    color: var(--text-900);
  }

  .message-time {
    font-size: 0.8rem;
    color: var(--text-400);
  }

  .message-subject {
    font-weight: 500;
    color: var(--text-600);
    margin-bottom: 0.25rem;
  }

  .message-preview {
    font-size: 0.85rem;
    color: var(--text-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--surface-200);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-600);
    text-decoration: none;
    border: 1px solid var(--surface-300);
    margin-top: 1rem;
  }

  .attachment-chip:hover {
    background: var(--surface-300);
  }

  /* Theme Selection Grid in Settings */
  .theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 0.5rem;
  }

  .theme-option {
    border: 2px solid var(--border-color);
    border-radius: var(--rounded-md);
    padding: 0.5rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
  }

  .theme-option:hover,
  .theme-option.active {
    border-color: var(--primary-500);
    background: var(--surface-100);
  }

  .theme-option.active {
    box-shadow: 0 0 0 2px var(--primary-500);
  }

  .theme-preview {
    height: 40px;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }