/* Global Styles & Variables */
:root {
    --primary-color: #f1b163;
    /* Indigo 500 */
    --primary-hover: #e57b46;
    /* Indigo 600 */
    --secondary-color: #64748b;
    /* Slate 500 */
    --bg-color: #f8fafc;
    /* Slate 50 */
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    /* Slate 800 */
    --text-secondary: #475569;
    /* Slate 600 */
    --border-radius: 20px;
    /* Increased for softer look */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    color: var(--text-primary);
}

.text-center.mb-4 {
    margin-bottom: 2rem !important;
    font-weight: 700;
    color: var(--primary-color);
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

.navbar-brand {
    font-weight: 700;
    color: var(--primary-color) !important;
}

/* Card & Container */
.container.mt-5 {
    margin-top: 5rem !important;
}

/* Buttons & Inputs */
.btn {
    border-radius: 50px;
    /* Fully rounded "Pill" style per request */
    padding: 0.5rem 1.25rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background-color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(241, 177, 99, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--secondary-color);
}

.btn-outline-secondary {
    border: 1px solid #cbd5e1;
    background: transparent;
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.form-control,
.form-select {
    border-radius: 20px;
    /* Softer inputs */
    border: 1px solid #e2e8f0;
    padding: 0.6rem 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(241, 177, 99, 0.2);
}

/* Table Styling (Desktop) */
#todoTable {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    width: 100% !important;
    border-collapse: collapse;
    /* Ensure no gaps */
}

table.dataTable thead th {
    background-color: #f1f5f9;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
    padding: 1rem;
}

table.dataTable tbody td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

/* Ensure actions don't wrap on desktop */
table.dataTable tbody td:last-child {
    white-space: nowrap;
    width: 1%;
}

table.dataTable.no-footer {
    border-bottom: none;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding: 1rem;
    color: var(--text-secondary);
}

/* Status Badges? (Optional, can style the text) */
.completed {
    text-decoration: line-through;
    color: #94a3b8;
}

/* Action Icons */
.action-btn {
    transition: transform 0.2s;
    color: var(--secondary-color);
}

.action-btn:hover {
    transform: scale(1.1);
}

.viewBtn:hover {
    color: var(--primary-color);
}

.editBtn:hover {
    color: #f59e0b;
}

.deleteBtn:hover {
    color: #ef4444;
}


/* --- Mobile Responsive (Card View) --- */
@media screen and (max-width: 768px) {

    /* Hide the table header completely */
    #todoTable thead {
        display: none;
    }

    /* Make rows behave like cards using Grid */
    #todoTable tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        /* Title/Desc take full, Status/Actions split */
        grid-template-rows: auto auto auto;
        gap: 0.5rem;

        background: var(--card-bg);
        border-radius: var(--border-radius);
        margin-bottom: 1.5rem;
        /* More space between cards */
        box-shadow: var(--shadow-sm);
        padding: 1.25rem;
        border: 1px solid #e2e8f0;
        position: relative;
    }

    #todoTable tbody td {
        display: block;
        border: none !important;
        padding: 0;
        text-align: left;
        width: auto;
        /* Reset width */
    }

    /* 1. Checkbox - Absolute Top Right */
    #todoTable tbody td:nth-child(1) {
        position: absolute;
        top: 1.25rem;
        right: 1.25rem;
        width: auto;
        height: auto;
        z-index: 10;
    }

    /* 2. Task Name - Row 1, Full Width (minus checkbox space) */
    #todoTable tbody td:nth-child(2) {
        grid-column: 1 / -1;

        font-weight: 700;
        font-size: 1.1rem;
        color: var(--primary-color);
        margin-bottom: 0.25rem;
        padding-right: 2rem;
        /* Avoid click conflict with checkbox */
    }

    #todoTable tbody td:nth-child(2)::before {
        content: none;
    }

    /* 3. Description - Row 2, Full Width */
    #todoTable tbody td:nth-child(3) {
        grid-column: 1 / -1;

        color: var(--text-secondary);
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
        line-height: 1.4;
    }

    #todoTable tbody td:nth-child(3)::before {
        content: none;
    }

    /* 4. Status - Row 3, Left Column */
    #todoTable tbody td:nth-child(4) {
        grid-column: 1 / 2;
        align-self: end;
    }

    #todoTable tbody td:nth-child(4)::before {
        content: none;
    }

    /* 5. Actions - Row 3, Right Column */
    #todoTable tbody td:nth-child(5) {
        grid-column: 2 / 3;
        justify-self: end;
        align-self: end;

        display: flex;
        gap: 0.75rem;
    }

    #todoTable tbody td:nth-child(5)::before {
        content: none;
    }

    /* Adjust Touch Targets */
    .action-btn {
        font-size: 1.1rem;
        padding: 0.5rem;
    }

    /* DataTables Controls Stacking */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: left;
        margin-bottom: 0.5rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        margin-left: 0;
        width: 100%;
        /* Full width search */
        margin-top: 0.25rem;
        border-radius: 50px;
        /* Rounded search */
    }

    /* Responsive Toolbar adjustments: Symmetrical Grid */
    .responsive-toolbar {
        gap: 0.75rem !important;
    }

    .responsive-toolbar>div {
        display: grid;
        grid-template-columns: 1fr 1fr;
        /* Two equal columns for symmetry */
        gap: 0.75rem;
        width: 100%;
    }

    /* Make "Add Task" span full width if it's the first item grouping, 
       but currently it's grouped with Filter and Bulk.
       Group 1: Add Task, Filter, Bulk Actions. 3 items. 
       Grid 1fr 1fr will leave a hole. Let's try to make the first one full width? 
       Or just keep it 1fr 1fr and let the last one stretch? */

    .responsive-toolbar>div>* {
        width: 100% !important;
        /* Force full width within grid cell */
    }

    /* Specific tweak: First group has 3 items (Add, Filter, Bulk). 
       Let's make Add Task full width on top. */
    .responsive-toolbar>div:first-child button#addTaskBtn {
        grid-column: 1 / -1;
    }

    .responsive-toolbar .btn,
    .responsive-toolbar .form-select,
    .responsive-toolbar .dropdown {
        border-radius: 50px;
    }

    /* Pagination Stacking */
    .dataTables_wrapper .dataTables_info {
        float: none;
        text-align: center;
        margin-bottom: 0.5rem;
        padding-top: 0;
    }

    .dataTables_wrapper .dataTables_paginate {
        float: none;
        text-align: center;
        margin-top: 0.5rem;
    }
}

/* Modal Polish */
.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: var(--shadow-md);
}

.modal-header {
    border-bottom: 1px solid #e2e8f0;
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #e2e8f0;
    padding: 1.5rem;
}

/* Badge Tweaks */
.badge {
    font-weight: 500;
    padding: 0.5em 0.8em;
}

/* Custom Colors for badges if Bootstrap ones aren't enough */
.bg-warning {
    background-color: #fef3c7 !important;
    color: #d97706 !important;
}

.bg-success {
    background-color: #dcfce7 !important;
    color: #166534 !important;
}