:root {
    --primary-color: #333;
    --border-color: #e2e8f0;
    --header-bg: #f8fafc;
    --text-color: #334155;
    --hover-bg: #f1f5f9;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
    margin: 0;
    padding: 16px 32px 32px 32px;
    /* Fixed PX */
    background-color: #fff;
    font-size: 14px;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 3px;
    /* Align with burger menu */
    margin-bottom: 2rem;
    color: #0f172a;
    text-align: left;
    padding-left: 40px;
    /* 32 + 40 = 72px */
    line-height: 1.2;
}

/* Controls (Dropdowns) */
.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
    justify-content: flex-start;
    /* Align left */
}

select {
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
}

select:focus {
    outline: 2px solid #94a3b8;
    border-color: #94a3b8;
}

/* Auth Buttons */
#auth-section {
    position: absolute;
    top: 2rem;
    right: 2rem;
    margin: 0;
}

.auth-btn {
    background-color: white;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.auth-btn:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

#signout_button {
    color: #ef4444;
    border-color: #fca5a5;
}

#signout_button:hover {
    background-color: #fef2f2;
    border-color: #ef4444;
}


/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
}

th,
td {
    padding: 6px 10px;
    /* Reduced from 8px 12px */
    text-align: left;
    border: 1px solid var(--border-color);
    font-size: 13px;
    /* Slightly smaller text for compact look */
}

th {
    background-color: var(--header-bg);
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    /* Matches recap page header size */
    letter-spacing: 0.05em;
    user-select: none;
    height: 30px;
    /* Force smaller header height */
}

th.sortable {
    cursor: pointer;
}

th.sortable:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

th span {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.4;
}

tbody tr:hover {
    background-color: var(--hover-bg);
}

/* Checkbox Column */
input[type="checkbox"] {
    cursor: pointer;
    accent-color: #0f172a;
    /* Dark styling for checked state */
}

/* Footer (Total) */
tfoot tr {
    background-color: #f8fafc;
    font-weight: 700;
}

tfoot td {
    border-top: 2px solid #cbd5e1;
    /* Slightly thicker top border for total */
    color: #0f172a;
}

#total-hours {
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

#status-message {
    text-align: left;
    margin-top: 1rem;
    font-size: 13px;
    color: #64748b;
}

/* Summary Section */
.summary-container {
    margin-top: 0.5rem;
    margin-bottom: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.summary-item {
    margin-bottom: 1.5rem;
}

.summary-client {
    font-weight: 700;
    font-size: 14px;
    color: #0f172a;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    /* Standardize client names */
}

.summary-dates {
    font-size: 13px;
    color: #334155;
    line-height: 1.5;
}

/* --- Calendar Styles (Prototype) --- */

.calendar-header {
    display: flex;
    justify-content: center;
    /* Center title and buttons */
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.calendar-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #0f172a;
    text-transform: capitalize;
    width: 200px;
    /* Fixed width to prevent shifting */
    text-align: center;
}

.delete-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    /* No underline */
    padding: 10px;
}

.delete-btn:hover {
    color: #ef4444;
    /* Keep same color */
    opacity: 0.8;
    /* Slight opacity change instead of color shift */
}

.calendar-header button {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    color: #64748b;
}

.weekdays-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 10px;
    font-size: 13px;
    text-transform: uppercase;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    /* Spacing between squares */
}

/* Weekend Styling: 6th and 7th columns in the grid */
.weekdays-grid div:nth-child(6),
.weekdays-grid div:nth-child(7),
.day-cell:nth-child(7n+6),
.day-cell:nth-child(7n) {
    background-color: #f8fafc;
    /* Light gray for weekends */
    color: #94a3b8;
}

.day-cell {
    min-height: 120px;
    /* Rectangular shape */
    border: 1px solid var(--border-color);
    background-color: #fff;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    position: relative;
}

.day-cell:hover {
    border-color: #94a3b8;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}



.day-cell.today {
    /* No background or border to match surroundings */
}

.day-number {
    font-weight: 700;
    font-size: 14px;
    color: #334155;
    margin-bottom: 5px;
}

/* Shortcut Buttons */
.shortcut-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    margin-top: -10px;
}

.shortcut-btn {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.shortcut-btn:hover {
    background-color: #f1f5f9;
    border-color: #bae6fd;
    color: #0284c7;
}

.day-number.today {
    color: #2563eb !important;
    /* Force Blue color */
    font-weight: 900;
    font-size: 16px;
}

.day-event {
    font-size: 11px;
    background-color: #f1f5f9;
    color: #334155;
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 2px;
    width: 100%;
    /* Flexbox for layout */
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping for project */
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    transition: opacity 0.2s;
}

.day-event:active {
    cursor: grabbing;
}

.day-event.dragging {
    opacity: 0.5;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.day-cell.drag-over {
    background-color: #e0f2fe;
    /* Light blue highlight */
    border-color: #3b82f6;
    border-style: dashed;
}

.event-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
}

.event-project {
    width: 100%;
    color: #64748b;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Status Dots (Global) */
.status-dot-calendar {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: absolute;
    top: 12px;
    left: 35px;
    /* Right of the number (padding 8 + width approx) */
    z-index: 10;
}

.dot-green {
    background-color: #22c55e;
}

.dot-orange {
    background-color: #f97316;
}

/* Mobile overrides for dots */
@media (max-width: 768px) {
    .status-dot-calendar {
        width: 5px;
        height: 5px;
        margin-top: -8px;
        position: relative;
        /* Back to relative flow for mobile layout */
        top: auto;
        left: auto;
    }
}

/* --- Modal Styles --- */
.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #fff;
    /* margin: 10% auto;  Removed for dynamic positioning */
    padding: 2rem;
    border-radius: 8px;
    width: 300px;
    /* Reduced width for better fit near mouse */
    /* max-width: 400px; */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    position: absolute;
    /* Changed from relative to absolute */
    /* top and left will be set by JS */
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover {
    color: #000;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #334155;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 16px;
    /* Prevents auto-zoom on mobile */
    box-sizing: border-box;
    font-family: inherit;
    /* Ensure font matches */
}

.save-btn {
    width: 100%;
    background-color: #0f172a;
    color: white;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.save-btn:hover {
    background-color: #334155;
}

.delete-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    padding: 10px;
}

.delete-btn:hover {
    color: #ef4444;
    /* Keep same color */
    opacity: 0.8;
    /* Slight opacity change instead of color shift */
}

/* --- Navigation Menu --- */
#burger-btn {
    position: fixed;
    top: 16px;
    /* Match body padding-top */
    left: 20px;
    font-size: 30px;
    cursor: pointer;
    color: #334155;
    z-index: 1000;
    transition: color 0.2s;
    line-height: 1;
    /* Tighten box */
}

#burger-btn:hover {
    color: #0f172a;
}

#side-menu {
    position: fixed;
    top: 0;
    left: -400px;
    /* Hidden by default */
    width: 400px;
    height: 100%;
    background-color: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    transition: left 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

#side-menu.open {
    left: 0;
}

#menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    /* No graying out */
    z-index: 1500;
    display: none;
    /* Still blocks clicks to underlying page, allowing click-to-close */
}

#menu-overlay.open {
    display: block;
    /* No opacity needed since it's transparent */
}

.menu-header {
    display: flex;
    justify-content: flex-start;
    /* Align left */
    padding: 2px 20px;
    /* Ultra-compact top padding */
}

.close-menu {
    font-size: 30px;
    cursor: pointer;
    color: #64748b;
}

.close-menu:hover {
    color: #000;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.menu-list li {
    border-bottom: none;
    /* Removed separator */
}

.menu-list li a {
    display: block;
    padding: 2px 30px;
    /* Ultra-compact padding */
    text-decoration: none;
    color: #64748b;
    /* Lighter gray */
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s;
}

.menu-list li a:hover {
    background-color: #f8fafc;
    color: #0f172a;
}

/* Menu Categories */
.menu-category {
    font-weight: 800;
    color: #0f172a;
    background-color: transparent;
    /* No background */
    padding: 4px 30px 2px 30px;
    /* Ultra-compact padding */
    font-size: 14px;
    letter-spacing: 0.05em;
    margin-top: 2px;
    text-transform: uppercase;
    border-bottom: none;
    /* No separator */
}

/* Disabled Items */
.menu-item.disabled {
    padding: 2px 30px;
    /* Synchronized with active links */
    color: #64748b;
    font-size: 16px;
    cursor: default;
    background-color: white;
}

/* Menu Container (New Structure) */
.menu-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    padding-top: 10px;
    width: 100%;
}

.menu-col {
    width: 50%;
}

/* Compact padding for 2-col mode */
.menu-list li a {
    padding: 4px 10px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-category {
    padding: 10px 10px 2px 10px;
    font-size: 12px;
}

/* Logout button adjustments for column width */
#menu-logout {
    font-size: 14px;
}

/* --- Mobile Responsiveness & Calendar --- */

/* Utility classes for responsive display */
.mobile-only {
    display: none !important;
    /* Force hide on desktop */
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    /* Mobile Menu Full Width */
    #side-menu {
        width: 100% !important;
        left: -100% !important;
    }

    #side-menu.open {
        left: 0 !important;
    }

    /* Reduce global padding on mobile */
    body {
        padding: 16px 5px !important;
        /* Top 16px to match burger */
        overflow-x: hidden;
        /* Prevent horizontal scroll */
    }

    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 10px !important;
        /* Internal breathing room */
        box-sizing: border-box !important;
    }

    h1 {
        padding-left: 57px !important;
        /* 5 + 10 + 57 = 72px */
        line-height: 1.2 !important;
        margin-top: 3px !important;
        /* Visual alignment */
    }

    /* Calendar Grid Adjustments */
    .calendar-grid {
        gap: 2px;
        border: none;
    }

    .day-cell {
        min-height: 40px;
        height: 40px;
        padding: 0;
        border: none;
        justify-content: center;
        align-items: center;
        background: transparent;
        box-shadow: none !important;
        transition: none;
    }

    .day-cell:hover {
        box-shadow: none !important;
        background: transparent !important;
        transform: none !important;
    }

    .day-event {
        display: none !important;
    }

    .day-number {
        font-size: 14px;
        margin-bottom: 2px;
        width: 36px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        border-radius: 50%;
    }

    .day-number.selected-day {
        background-color: #0f172a;
        color: white !important;
        box-shadow: none;
    }

    .day-cell.today .day-number:not(.selected-day) {
        color: #2563eb;
    }

    .day-cell.today {
        background-color: transparent !important;
    }

    .day-cell:nth-child(7n),
    .day-cell:nth-child(7n+6) {
        background-color: #f8fafc !important;
    }



    .weekdays-grid div {
        font-size: 0;
    }

    .weekdays-grid div::first-letter {
        font-size: 12px;
        visibility: visible;
    }

    .weekdays-grid div::after {
        content: none;
    }

    #mobile-details-container {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #f1f5f9;
    }

    .mobile-event-item {
        background-color: #f1f5f9;
        border: none;
        padding: 8px 12px;
        border-radius: 6px;
        margin-bottom: 6px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-shadow: none;
    }

    .mobile-event-info {
        display: flex;
        flex-direction: row;
        align-items: baseline;
        gap: 8px;
        overflow: hidden;
    }

    .mobile-client {
        font-weight: 700;
        color: #1e293b;
        font-size: 14px;
        white-space: nowrap;
    }

    .mobile-project {
        font-size: 11px;
        color: #64748b;
        text-transform: uppercase;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-hours {
        font-weight: 400;
        color: #334155;
        font-size: 14px;
        margin-left: auto;
    }

    .mobile-add-wrapper {
        display: flex;
        justify-content: center;
        margin-top: 15px;
        padding-bottom: 40px;
    }

    .floating-add-btn {
        width: 45px;
        height: 45px;
        background-color: #0f172a;
        color: white;
        border-radius: 50%;
        font-size: 24px;
        border: none;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Ultra-compact 2-line layout for Spark mobile cards */
    .spark-table {
        border: none !important;
        width: 100% !important;
        border-collapse: collapse !important;
        margin: 0 !important;
    }

    .spark-table thead {
        display: none !important;
    }

    .spark-table tbody,
    .spark-table tr {
        display: block !important;
        width: 100% !important;
    }

    .spark-table tr {
        display: flex !important;
        flex-wrap: wrap !important;
        margin-bottom: 0 !important;
        /* NO GAP between cards */
        border: 1px solid #e2e8f0 !important;
        border-top: none !important;
        /* Remove top border to collapse with previous */
        border-radius: 0 !important;
        /* Sharp corners for stacking */
        background: #fff !important;
        padding: 6px 12px !important;
        box-shadow: none !important;
        /* No shadow to keep it flat block */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .spark-table tr:first-child {
        border-top: 1px solid #e2e8f0 !important;
        border-top-left-radius: 8px !important;
        border-top-right-radius: 8px !important;
    }

    .spark-table td {
        display: block !important;
        border: none !important;
        padding: 0 !important;
        min-height: auto !important;
        font-size: 13px !important;
        background: transparent !important;
    }

    .spark-table td[data-label="Client"],
    .spark-table td[data-label="Projet"],
    .spark-table td.empty-comment {
        display: none !important;
    }

    .spark-table td[data-label="Date"] {
        order: 1;
        width: 50% !important;
        text-align: left !important;
        color: #1e293b;
        font-weight: 600;
        margin: 0 !important;
    }

    .spark-table td[data-label="Date"]::before {
        content: none !important;
    }

    .spark-table td[data-label="Heures"] {
        order: 2;
        width: 50% !important;
        text-align: right !important;
        font-weight: 700;
        color: #0f172a;
        margin: 0 !important;
    }

    .spark-table td[data-label="Heures"]::before {
        content: none !important;
    }

    .spark-table td[data-label="Commentaire"] {
        order: 3;
        width: 100% !important;
        text-align: left !important;
        color: #64748b;
        font-size: 11px !important;
        padding-top: 2px !important;
        word-break: break-word;
    }

    .spark-table td[data-label="Commentaire"]::before {
        content: "Commentaire : " !important;
        position: static !important;
        font-weight: 600;
        color: #94a3b8;
        font-size: 9px;
        text-transform: uppercase;
    }

    .spark-table tfoot {
        display: block !important;
        margin-top: 0;
        /* NO GAP between cards and total */
    }

    .spark-table tfoot tr {
        display: flex !important;
        justify-content: center !important;
        padding: 10px !important;
        background: #f8fafc !important;
        border-radius: 0 !important;
        /* Stacking */
        border-bottom-left-radius: 8px !important;
        /* Rounded bottom corners */
        border-bottom-right-radius: 8px !important;
        border: 1px solid #e2e8f0 !important;
        border-top: none !important;
        /* Collapse border */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .spark-table tfoot td {
        padding: 0 !important;
        width: auto !important;
        display: inline !important;
        font-weight: bold !important;
        font-size: 16px !important;
    }

    .spark-table tfoot td[colspan] {
        display: none !important;
    }

    .spark-table .total-row td#total-hours::before {
        content: "TOTAL : " !important;
        font-size: 13px;
        margin-right: 5px;
    }
}

/* MINIMALIST LOGIN FULLSCREEN */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #ffffff;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 40vh;
    align-items: center;
    transition: opacity 0.3s ease;
}

.login-minimal-container {
    display: flex;
    align-items: center;
    padding-bottom: 5px;
    width: 300px;
}

#login-pass {
    border: none;
    outline: none;
    font-size: 1.5rem;
    flex-grow: 1;
    color: #0f172a;
    background: transparent;
    padding: 10px;
    font-family: inherit;
    text-align: center;
}

#login-pass::placeholder {
    color: #cbd5e1;
    font-weight: 300;
}

/* Legacy Login Box (Backup) */
.login-box {
    background-color: white;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h2 {
    margin-top: 0;
    color: #1e293b;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-box p {
    color: #64748b;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.login-box input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1rem;
    box-sizing: border-box;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-box button:hover {
    background-color: #1d4ed8;
}

#login-error {
    color: #ef4444;
    margin-top: 1rem;
    margin-bottom: 0;
    font-weight: 500;
    min-height: 1.5rem;
}