/* static/css/style.css */
:root {
    --bg-primary: #eeece2; /* Off-white background */
    --bg-secondary: #ffffff; /* White for cards/sidebar */
    --bg-tertiary: #f5f5f5; /* Light grey for hover */
    --text-primary: #3d3929; /* Warm dark brown text */
    --text-secondary: #757575; /* Grey for secondary text */
    --border-color: #e0e0e0;
    --accent-color: #da7756; /* Terra Cotta primary */
    --danger: #a53232;
    --font-sans: 'Inter', sans-serif;
}

body {
    font-family: var(--font-sans);
    margin: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6; /* Improved readability */
}

.app-layout {
    display: flex;
    height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
}
.sidebar-header { display: flex; align-items: center; gap: 0.5rem; padding: 0 0.5rem; margin-bottom: 1rem; }
.sidebar-logo { font-size: 1.5rem; font-weight: bold; }
.sidebar-title { font-size: 1.2rem; margin: 0; }

.sidebar-nav { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.2s, color 0.2s;
}
.sidebar-nav a:hover { background-color: var(--bg-tertiary); color: var(--text-primary); }
.sidebar-nav a.active { background-color: var(--bg-tertiary); color: var(--text-primary); font-weight: 500;}
.sidebar-nav a i { width: 16px; text-align: center; }

.sidebar-footer { margin-top: auto; }
.user-profile { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; }
.user-avatar {
    width: 24px; height: 24px; border-radius: 50%; background-color: var(--accent-color);
    display: flex; align-items: center; justify-content: center; font-weight: bold; color: white;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.container { /* General purpose container */
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap; /* Allow wrapping */
    gap: 1rem;
}
.content-header h1 { font-size: 1.8rem; margin: 0; } /* Slightly smaller h1 */
.header-actions { display: flex; gap: 0.75rem; }

/* Buttons */
.btn {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none; /* Ensure links styled as buttons look right */
    display: inline-block; /* Alignment */
    text-align: center;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.btn:hover {
    background-color: #e9e9e9;
    border-color: #ccc;
}
.btn-primary {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--bg-secondary);
}
.btn-primary:hover {
    background-color: #c15f3c; /* Darker accent */
    border-color: #c15f3c;
}
.btn.danger {
    background-color: var(--danger);
    border-color: var(--danger);
    color: white;
}
.btn.danger:hover {
    background-color: #8c2a2a; /* Darker danger */
    border-color: #8c2a2a;
}
.btn-small { padding: 4px 10px; font-size: 0.9em; }

/* --- Project Cards --- */
/* ... (Project card styles remain the same) ... */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.project-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}
.card-header { margin-bottom: 1rem; }
.card-category { color: var(--text-secondary); font-size: 0.8rem; margin-bottom: 0.5rem; }
.card-title { font-size: 1.2rem; margin: 0; color: var(--text-primary); }
.project-card a { text-decoration: none; } /* Remove underline from card links */
.project-card a:hover .card-title { color: var(--accent-color); } /* Highlight title on hover */

.card-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    height: 40px; /* Fixed height for alignment */
    overflow: hidden;
    line-height: 1.4;
}
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
}
.avatar-stack img {
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    margin-left: -8px;
}
.avatar-stack img:first-child { margin-left: 0; }
.task-count { font-size: 0.9rem; color: var(--text-secondary); }

/* Progress Bar */
.progress-bar {
    width: 100%; height: 6px; background-color: var(--bg-tertiary);
    border-radius: 3px; margin-top: 1rem; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; background-color: var(--accent-color); border-radius: 3px;
}


/* Table Styles */
.table-container {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow-x: auto; /* Allow horizontal scroll on small screens if needed */
}
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: 12px 15px; border: 1px solid var(--border-color); text-align: left; vertical-align: middle; }
th { background-color: var(--bg-tertiary); font-weight: 600; }
.user-cell { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar-small {
    width: 32px; height: 32px; border-radius: 50%; background-color: var(--accent-color);
    display: flex; align-items: center; justify-content: center; font-weight: bold;
    color: var(--bg-secondary); flex-shrink: 0;
}

/* Settings Page */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2rem; }
.form-container.container { margin: 0; } /* Reset margin for grid items */

/* Messages & Alerts */
.messages { list-style: none; padding: 0; margin: 1rem 0; }
.alert-success, .alert-error, .alert-info {
    padding: 1rem; border-radius: 5px; margin-bottom: 0.5rem; border: 1px solid transparent;
}
.alert-success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.alert-error { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.alert-info { background-color: #d1ecf1; color: #0c5460; border-color: #bee5eb; }


/* Filter Form */
.filter-form {
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    gap: 1rem;
    align-items: center;
}
.filter-fields {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    gap: 1rem;
    flex-grow: 1;
}
.filter-fields select, .filter-fields input {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem; /* Match button padding */
    border-radius: 5px;
    border-width: 1px;
    border-style: solid;
}

/* Modal Styles */
/* ... (Modal styles remain the same) ... */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); }
.modal-content { background-color: var(--bg-secondary); margin: 10% auto; padding: 2rem; border: 1px solid var(--border-color); border-radius: 8px; width: 90%; max-width: 500px; position: relative; }
.close-button { color: var(--text-secondary); position: absolute; top: 10px; right: 20px; font-size: 28px; font-weight: bold; }
.close-button:hover, .close-button:focus { color: var(--text-primary); text-decoration: none; cursor: pointer; }


/* --- PROJECT DETAIL PAGE --- */

.admin-actions-box {
    border: 1px solid var(--border-color);
    padding: 1rem;
    margin: 1.5rem 0;
    background-color: var(--bg-secondary);
    border-radius: 8px;
}
.admin-actions-box h4 { margin-top: 0; }
.admin-actions-box form label { margin-bottom: 0; } /* Fix label margin */
.admin-actions-box form select { flex-grow: 1; } /* Allow select to grow */

.task-filter-form { margin-top: 1.5rem; }

.task-list {
    margin-top: 1.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
}

.task-item { border-bottom: 1px solid var(--border-color); }
.task-item:last-child { border-bottom: none; }

.task-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-wrap: wrap; /* Allow wrapping */
}
.task-summary:hover { background-color: var(--bg-tertiary); }

.task-status {
    padding: 0.2rem 0.6rem;
    border-radius: 12px; /* Pill shape */
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
    border: 1px solid transparent;
}
/* More distinct status colors */
.status-backlog { background-color: #e0e0e0; color: #616161; border-color: #bdbdbd; }
.status-not_started { background-color: #fff3e0; color: #e65100; border-color: #ffe0b2; }
.status-in_progress { background-color: #e3f2fd; color: #0d47a1; border-color: #bbdefb; }
.status-completed { background-color: #e8f5e9; color: #1b5e20; border-color: #c8e6c9; }
.status-due { background-color: #ffebee; color: #c62828; border-color: #ffcdd2; }



.task-title {
    flex-grow: 1;
    font-weight: 600;
    min-width: 150px; /* Prevent title from becoming too small */
}
.task-assignee, .task-due, .task-indicators {
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    white-space: nowrap; /* Prevent wrapping */
}
.task-assignee i, .task-due i, .task-indicators i { margin-right: 0.3rem; }
.task-indicators i { margin-left: 0.5rem; }


.task-details {
    padding: 1.5rem;
    border-top: 1px dashed var(--border-color);
    background-color: #fdfdfd;
}
.task-item.is-expanded .task-summary { background-color: var(--bg-tertiary); } /* Highlight expanded */

.task-detail-header {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.task-detail-header p { flex-basis: 100%; margin: 0; flex-grow: 1; } /* Description takes full width first */
.task-status-update-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-basis: auto; /* Allow form to sit beside description if space */
}
.task-status-update-form label { margin-bottom: 0; font-size: 0.9em; white-space: nowrap; }
.task-status-update-form select { padding: 4px 8px; font-size: 0.9em; }

.task-detail-tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 1rem; }
.tab-button { padding: 0.75rem 1.25rem; cursor: pointer; background: none; border: none; border-bottom: 3px solid transparent; color: var(--text-secondary); font-weight: 500; font-size: 0.9rem; }
.tab-button.active { color: var(--accent-color); border-bottom-color: var(--accent-color); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.task-comments {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    background-color: #fff;
}
.comment { padding-bottom: 0.75rem; margin-bottom: 0.75rem; border-bottom: 1px solid #f0f0f0; }
.comment:last-child { border-bottom: none; }
.comment p { margin: 0.25rem 0; }
.comment-date { font-size: 0.8rem; color: #888; margin-left: 0.5rem; }

.comment-form { display: flex; gap: 0.5rem; align-items: flex-start; }
.comment-form textarea { flex-grow: 1; height: auto; resize: vertical; min-height: 40px; }
.comment-form button { flex-shrink: 0; align-self: flex-end; } /* Align button nicely */

.attachments-list ul { list-style: none; padding: 0; margin: 0 0 1rem 0; }
.attachments-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border-color); }
.attachments-list li:last-child { border-bottom: none; }
.attachments-list a { font-weight: 500; }
.attachment-details { font-size: 0.8em; color: var(--text-secondary); margin-left: 0.5rem; }

.attachment-form { display: flex; align-items: center; gap: 1rem; }
.attachment-form input[type="file"] { border: none; padding: 0; flex-grow: 1; }

/* ########################################## */
/* ############### MOBILE FIXES ############### */
/* ########################################## */

.menu-toggle { display: none; }

@media (max-width: 768px) {
    .app-layout { display: block; }

    .sidebar { position: fixed; left: -260px; top: 0; height: 100%; z-index: 2000; transition: left 0.3s ease-in-out; }
    .sidebar.sidebar-open { left: 0; }

    .main-content { width: 100%; padding: 1rem; box-sizing: border-box; }
    .content-header { padding-top: 4.5rem; /* More space for menu button */ flex-direction: column; align-items: flex-start; gap: 1rem; }

    .menu-toggle { display: block; position: fixed; top: 15px; left: 15px; z-index: 2001; background: var(--bg-secondary); border: 1px solid var(--border-color); padding: 0.5rem; border-radius: 5px; cursor: pointer; color: var(--text-primary); font-size: 1.5rem; }

    /* Responsive Filter */
    .filter-form, .filter-fields { flex-direction: column; align-items: stretch; }
    .filter-form button { align-self: flex-end; }

    /* Responsive Tables */
    .table-container { border: none; padding: 0; background: none; }
    table thead { display: none; }
    table, table tbody, table tr, table td { display: block; width: 100%; }
    table tr { margin-bottom: 1rem; border: 1px solid var(--border-color); border-radius: 8px; background-color: var(--bg-secondary); padding: 0.5rem; }
    table td { text-align: right; padding-left: 50%; position: relative; border: none; padding-bottom: 0.5rem; padding-top: 0.5rem; display: flex; align-items: center; justify-content: flex-end;}
    table td::before { content: attr(data-label); position: absolute; left: 10px; width: 45%; padding-right: 10px; text-align: left; font-weight: bold; color: var(--text-primary); }
    .user-cell { justify-content: flex-end; } /* Align user cell content */

    /* Responsive Task List */
    .task-summary { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .task-title { width: 100%; margin: 0; order: -1; /* Move title to top */}
    .task-status { order: -2; /* Move status even higher */}
    .task-assignee, .task-due, .task-indicators { width: 100%; }

    /* Settings Page Grid */
    .settings-grid { grid-template-columns: 1fr; }
}

.task-summary .edit-task-btn {
    margin-left: auto; /* Push edit button to the right */
    visibility: hidden; /* Hide by default */
    opacity: 0;
    transition: visibility 0s linear 0.2s, opacity 0.2s linear;
}
.task-summary:hover .edit-task-btn {
    visibility: visible; /* Show on hover */
    opacity: 1;
    transition-delay: 0s;
}

.subtask-list {
    margin-bottom: 1rem;
}
.subtask-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}
.subtask-item:last-child {
    border-bottom: none;
}
.subtask-status-form select {
    padding: 2px 5px;
    font-size: 0.8em;
}
.subtask-title {
    flex-grow: 1;
}
.subtask-assignee {
    font-size: 0.85em;
    color: var(--text-secondary);
}
.add-subtask-action {
    margin-top: 1rem;
}


/* Add to static/css/style.css */

.status-locked-message {
    display: flex;
    align-items: center;
}

.overdue-activity {
    border-left: 3px solid var(--danger);
    padding-left: 10px;
}

.overdue-tag {
    font-size: 0.75em;
    color: var(--danger);
    background-color: #ffebee;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ------ MOBILE LAYOUT FIX (FullCalendar v6.x) ------ */

@media (max-width: 768px) {

    .fc-header-toolbar {
        flex-direction: column !important;
        align-items: center !important;
        gap: 12px !important;
    }

    .fc-toolbar-chunk {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .fc-toolbar-title {
        text-align: center !important;
        font-size: 1.4rem !important;
        width: 100%;
    }

    .fc .fc-button {
        padding: 8px 14px !important;
        font-size: 0.9rem !important;
    }
}

/* Custom Header Action Button */

.btn-manage-cat {
    background-color: #fff;
    border: 1px solid #da7756; /* Terra Cotta */
    color: #da7756;
    padding: 10px 16px; /* Match standard btn size */
    border-radius: 4px; /* Match standard radius */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    margin-right: 10px; /* Space between buttons */
    font-size: 14px;
}
.btn-manage-cat:hover {
    background-color: #da7756;
    color: white;
}

.project-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    background: transparent;
}

/* SOLO — Terra Cotta Outline */
.badge-solo-outline {
    color: var(--accent-color);          /* #da7756 */
    border: 1px solid var(--accent-color);
}

/* TEAM — Muted Earth Outline */
.badge-team-outline {
    color: #5f6b4f;                      /* olive-grey */
    border: 1px solid #c9d2c3;           /* soft sage border */
}


/* Force all avatars to align perfectly */
.avatar-group {
    display: flex;
    align-items: center; /* Centers them vertically */
    padding-left: 10px; /* Space for the negative overlap */
}

.avatar-group img.user-avatar, 
.avatar-group .user-avatar {
    width: 32px;       /* Enforce strict width */
    height: 32px;      /* Enforce strict height */
    border-radius: 50%;
    border: 2px solid white; /* Clean separator */
    object-fit: cover; /* Prevents image distortion */
    
    /* Flex alignment fixes "floating" */
    display: flex;
    align-items: center;
    justify-content: center;
    
    margin-left: -10px; /* The overlap effect */
    font-size: 12px;
    font-weight: 600;
    background-color: #da7756; /* Fallback color */
    color: white;
    vertical-align: middle;
}

/* Ensure the image specifically resets inline behaviors */
.avatar-group img.user-avatar {
    background-color: white; /* Avoid color bleeding behind transparent images */
}
