/* =============================================================================
   MAINTENANCE SYSTEM - CENTRALIZED STYLES
   ============================================================================= */

/* Dashboard Styles */
/* Remove ALL borders from list-group-items first */
.list-group-flush .list-group-item {
    border: none !important;
}

/* Add top border to parent tasks (except the first one) */
.list-group-flush .task-parent ~ .task-parent {
    border-top: 1px solid #dee2e6 !important;
}

/* But remove border if there are subtasks between parent tasks */
.list-group-flush .task-subtask ~ .task-parent {
    border-top: 1px solid #dee2e6 !important;
}

.badge-sm {
    font-size: 0.7em;
    padding: 0.2em 0.4em;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.user-badge {
    transition: background-color 0.2s ease;
}

.user-badge:hover {
    background-color: #495057 !important;
    transform: scale(1.05);
}

.recent-users .d-flex {
    gap: 0.25rem;
}

/* Admin Styles */
.card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table th {
    border-top: none;
}

.btn-group .btn {
    border-radius: 0.25rem;
    margin-right: 0.25rem;
}

.btn-group .btn:last-child {
    margin-right: 0;
}

.gap-1 > * {
    margin-right: 0.25rem !important;
    margin-bottom: 0.25rem !important;
}

/* Form Styles */
.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.input-group-text {
    min-width: 50px;
    justify-content: center;
}

.form-control-color {
    max-width: 60px;
}

/* Task container layout */
.task-container {
    display: flex;
    flex-direction: column;
}

/* Desktop layout: task name and buttons on same line */
@media (min-width: 577px) {
    .task-name-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.25rem;
    }
    
    .task-title-content {
        flex: 1;
        min-width: 0;
        margin-right: 1rem;
    }
    
    .task-buttons-desktop {
        flex-shrink: 0;
    }
    
    .task-tags-row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        margin-bottom: 0.25rem;
        padding-left: 0;
        padding-right: 1rem;
    }
    
    .card-header .header-actions {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
}

/* ===================== MOBILE RESPONSIVE IMPROVEMENTS ===================== */
@media (max-width: 576px) {
    .card-header.d-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.25rem;
    }
    .card-header .header-actions {
        width: 100%;
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        margin-top: 0.25rem;
        margin-bottom: 0;
        justify-content: flex-start;
        padding-left: 0;
    }
    .card-header .header-actions .btn {
        margin-right: 0;
    }
    .card-header h5 {
        margin-bottom: 0 !important;
    }
    
    /* Quick add form: input and button same height, button not full width */
    .card-body form.d-flex, .p-3 form.d-flex {
        flex-direction: row !important;
        gap: 0.5rem;
    }
    .card-body form.d-flex input,
    .p-3 form.d-flex input {
        width: 0;
        flex: 1 1 auto;
        min-width: 0;
    }
    .card-body form.d-flex button,
    .p-3 form.d-flex button {
        width: auto;
        min-width: 44px;
        height: 38px;
        padding: 0 1em;
        font-size: 1em;
    }
    
    /* Mobile layout: stack task name, tags, buttons vertically (all left) */
    .task-container {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .task-name-row {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .task-title-content {
        width: 100%;
    }
    
    .task-tags-row {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .task-buttons-row {
        width: 100%;
        position: static !important;
        justify-content: flex-start;
    }
    
    /* Badges: smaller font and padding */
    .badge, .badge-sm {
        font-size: 0.75em !important;
        padding: 0.2em 0.5em !important;
    }
    
    /* Action buttons: consistent size */
    .btn, .btn-sm {
        font-size: 1em !important;
        padding: 0.25em 0.75em !important;
        min-width: 38px;
        min-height: 38px;
        height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .btn .badge {
        font-size: 0.75em !important;
        padding: 0.1em 0.4em !important;
        margin-left: 0.25em;
    }
    
    /* Restore subtask indentation, but less than desktop */
    .task-subtask, .task-depth-1 { padding-left: 1.5rem !important; }
    .task-depth-2 { padding-left: 2.5rem !important; }
    .task-depth-3 { padding-left: 3.5rem !important; }
    .task-depth-4 { padding-left: 4.5rem !important; }
    
    /* Prevent horizontal overflow */
    .list-group-flush {
        overflow-x: auto;
    }
    
    /* Task title: allow wrapping */
    .list-group-item strong {
        word-break: break-word;
    }
}

/* Task Filtering Styles */
.tag-filter-btn,
.assignee-filter-btn {
    transition: all 0.2s ease;
    border-radius: 15px;
    font-size: 0.8rem;
    position: relative;
    margin: 4px 2px;
    overflow: visible;
}

.tag-filter-btn:hover,
.assignee-filter-btn:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tag-filter-btn.btn-primary,
.assignee-filter-btn.btn-primary {
    border-color: var(--bs-primary);
    box-shadow: 0 3px 6px rgba(13, 110, 253, 0.3);
    transform: scale(1.02);
    font-weight: bold;
}

.tag-filter-btn.btn-primary:hover,
.assignee-filter-btn.btn-primary:hover {
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.4);
    transform: translateY(-1px) scale(1.04);
}

.tag-filter-btn.btn-primary::before,
.assignee-filter-btn.btn-primary::before {
    content: '✓';
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--bs-success);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#available-tags,
#available-assignees {
    max-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    margin: -8px 0;
}

#available-tags::-webkit-scrollbar {
    width: 6px;
}

#available-tags::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#available-tags::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#available-tags::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.filter-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    overflow: visible;
}

.filter-section .row,
.filter-section .col-md-6 {
    overflow: visible;
}

/* Filter Toggle Styles */
.cursor-pointer {
    cursor: pointer;
}

.transition-all {
    transition: all 0.2s ease;
}

#filter-toggle-header:hover {
    background-color: #e9ecef !important;
}

#filter-content {
    transition: all 0.3s ease;
}

#active-filters-summary {
    font-style: italic;
}

#clear-filters-btn {
    color: var(--bs-danger);
    text-decoration: none;
    font-size: 0.8rem;
}

#clear-filters-btn:hover {
    color: var(--bs-danger);
    text-decoration: underline;
}

@media (max-width: 768px) {
    #available-tags,
    #available-assignees {
        max-height: 80px;
        padding: 6px 0;
        margin: -6px 0;
    }
    
    .tag-filter-btn,
    .assignee-filter-btn {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
        margin: 3px 1px;
    }
    
    .tag-filter-btn.btn-primary::before,
    .assignee-filter-btn.btn-primary::before {
        width: 14px;
        height: 14px;
        font-size: 9px;
        top: -4px;
        right: -4px;
    }
}
