@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Sophisticated Professional Palette - Slate & Indigo */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #6366f1;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Neutral High-Contrast Grays */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --dark: var(--slate-900);
    --gray: var(--slate-500);
    --light-gray: var(--slate-100);
    --white: #ffffff;
    --border: var(--slate-200);

    /* Refined Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.08);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Fonts */
    --font-body: 'Inter', -apple-system, system-ui, sans-serif;
    --font-heading: 'Inter', -apple-system, system-ui, sans-serif;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--slate-800);
    background-color: var(--slate-100);
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-xl);
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--slate-900);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-outline {
    background: var(--white);
    border-color: var(--slate-200);
    color: var(--slate-700);
}

.btn-outline:hover {
    background: var(--slate-50);
    border-color: var(--slate-300);
    color: var(--slate-900);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

/* Badges */
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-priority-low {
    background: #ecfdf5;
    color: #065f46;
}

.badge-priority-medium {
    background: #fffbeb;
    color: #92400e;
}

.badge-priority-high {
    background: #fef2f2;
    color: #991b1b;
}

.badge-status-todo {
    background: var(--slate-100);
    color: var(--slate-700);
}

.badge-status-in_progress {
    background: #eff6ff;
    color: #1e40af;
}

.badge-status-completed {
    background: #ecfdf5;
    color: #065f46;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 95%;
    /* Better mobile width */
    max-width: 650px;
    max-height: 90vh;
    /* Don't exceed screen height */
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.modal-close {
    background: var(--slate-50);
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--slate-400);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--slate-100);
    color: var(--slate-600);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    /* Take remaining space */
}

/* Ensure forms inside modals are flex containers */
.modal-content form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Scrollbar styling for modal body */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--slate-200);
    border-radius: 10px;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    background: white;
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--slate-600);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Multi-select improvement */
select[multiple] {
    padding: 0.5rem;
    background-image: none;
    /* Remove default arrow */
    min-height: 100px;
}

select[multiple] option {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}

select[multiple] option:checked {
    background: var(--primary) linear-gradient(0deg, var(--primary) 0%, var(--primary) 100%) !important;
    color: white !important;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    background-color: var(--white);
    color: var(--slate-900);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

input::placeholder,
textarea::placeholder {
    color: var(--slate-400);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    transform: translateY(-1px);
}

/* Custom Checkbox */
.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    color: var(--slate-700);
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: relative;
    height: 22px;
    width: 22px;
    background-color: var(--slate-100);
    border: 2px solid var(--border);
    border-radius: 6px;
    transition: all 0.2s;
}

.custom-checkbox:hover input~.checkmark {
    background-color: var(--slate-200);
    border-color: var(--slate-400);
}

.custom-checkbox input:checked~.checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-checkbox input:checked~.checkmark:after {
    display: block;
}

/* File input styling */
.form-control-file {
    padding: 0.5rem;
    background: var(--slate-50);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.form-control-file:hover {
    background: var(--slate-100);
    border-color: var(--primary-light);
}

/* Tag selection in modal */
.tag-selection-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.modal-tag {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.modal-tag:hover {
    background: var(--slate-50);
    border-color: var(--slate-300);
}

.modal-tag.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.modal-tag input {
    display: none;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

/* Alert */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    color: #92400e;
}

/* Navigation Fix */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-xl);
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.025em;
}

.navbar-toggle {
    display: none;
}

.navbar-menu {
    display: flex;
    gap: var(--spacing-lg);
}

.nav-link {
    color: var(--slate-600);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
}

.nav-link.active {
    border-bottom-color: var(--primary);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-badge {
    background: var(--slate-100);
    color: var(--slate-700);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Utilities */
.text-muted {
    color: var(--slate-500);
}

.text-center {
    text-align: center;
}

/* Global Utilities */
.italic {
    font-style: italic;
}

.text-danger {
    color: var(--danger);
}

/* Tag Components */
.tag-selection-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.modal-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-tag:hover {
    background: var(--slate-100);
    border-color: var(--slate-300);
}

.modal-tag.selected {
    border-color: var(--primary);
    background: #eef2ff;
    color: var(--primary);
}

.tag-checkbox {
    display: none;
}

.task-tag-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: var(--slate-100);
    color: var(--slate-600);
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.task-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    margin-top: 4px;
}

/* Deadline status */
.deadline-overdue {
    color: var(--danger) !important;
    font-weight: 700;
}

.deadline-critical {
    color: var(--warning) !important;
    font-weight: 700;
}

/* Mini Checkbox for 'All Day' toggle */
.custom-checkbox-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--slate-500);
    cursor: pointer;
    user-select: none;
}

.custom-checkbox-mini input {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
}

/* Notification Styles */
.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--slate-600);
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--slate-100);
}

.notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 10px;
    border: 2px solid white;
    font-weight: 800;
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-top: 10px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    border: 1px solid var(--border);
}

.notification-dropdown.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.notification-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--slate-100);
    transition: background 0.2s;
    cursor: pointer;
}

.notification-item:hover {
    background: var(--slate-50);
}

.notification-item.unread {
    background: #eff6ff;
}

.notification-item .title {
    font-weight: 600;
    color: var(--slate-900);
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.notification-item .message {
    color: var(--slate-600);
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.notification-item .time {
    color: var(--slate-400);
    font-size: 0.65rem;
}

.btn-text-sm {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.7rem;
    cursor: pointer;
    font-weight: 600;
}

.btn-text-sm:hover {
    text-decoration: underline;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Mobile Styles */
@media (max-width: 992px) {
    .navbar-container {
        flex-wrap: wrap;
        padding: 0 var(--spacing-md);
    }

    .navbar-brand {
        flex: 1;
    }

    .navbar-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        color: var(--slate-700);
        order: 2;
    }

    .navbar-menu {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        padding: 1rem 0;
        order: 3;
        border-top: 1px solid var(--border);
        margin-top: 1rem;
    }

    .navbar-menu.active {
        display: flex;
        animation: slideDown 0.3s ease-out;
    }

    .nav-link {
        padding: 0.75rem 1rem;
        width: 100%;
        border-radius: var(--radius);
    }

    .navbar-user {
        order: 1;
        margin-right: 10px;
    }

    .user-badge {
        display: none;
        /* Hide name on mobile to save space */
    }

    .container {
        padding: 0 var(--spacing-md);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
    }

    .search-box,
    .search-box input {
        width: 100% !important;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    /* Modal adjustments for mobile */
    .modal-content {
        width: 98%;
        max-height: 95vh;
        margin: 0.5rem;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-footer {
        padding: 1rem 1.25rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }

    /* Cards on mobile */
    .card {
        border-radius: var(--radius);
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Buttons on mobile */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
        border-radius: var(--radius) !important;
        margin-bottom: 0.5rem;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon-wrapper {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-group label {
        font-size: 0.75rem;
    }

    input,
    select,
    textarea {
        font-size: 0.85rem;
        padding: 0.6rem 0.75rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .modal-header h3 {
        font-size: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Multi-select improvement */
select[multiple] {
    height: auto;
    padding: 5px;
}

select[multiple] option {
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 2px;
}

select[multiple] option:checked {
    background-color: var(--primary) !important;
    color: white !important;
}