/* ===========================================
   Admin-specific styles
   Note: common.css must be loaded first
   =========================================== */

/* Admin stats grid */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow);
}

.stat-card h3 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.stat-card a.btn-primary {
    margin-top: 12px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Admin actions grid */
.admin-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    transition: all 0.2s ease;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow);
    border-color: var(--primary-color);
}

.action-card h3 {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.action-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Users table */
.users-table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 40px;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.users-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--text-primary);
}

.users-table tr:hover {
    background: var(--gray-50);
}

.user-roles {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.role-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-small);
    font-size: 0.75rem;
    font-weight: 500;
    margin: 0 4px;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-small);
    text-decoration: none;
    line-height: 1.4;
    box-sizing: border-box;
    height: 32px;
}

.text-muted {
    color: var(--text-secondary);
    font-style: italic;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px var(--shadow);
    z-index: 1001;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.roles-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    margin-top: 4px;
}

.checkbox-group label {
    font-weight: 500;
    cursor: pointer;
    line-height: 1.4;
}

/* ===========================================
   Feedbacks admin table
   =========================================== */

/* Filters bar */
.filters-bar {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.filters-bar form,
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-select,
.filter-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 0.9rem;
    min-width: 150px;
    background: var(--background);
    height: 38px;
    box-sizing: border-box;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.btn-reset {
    align-self: flex-end;
}

/* Feedbacks table */
.feedbacks-table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 40px;
}

.feedbacks-table {
    width: 100%;
    border-collapse: collapse;
}

.feedbacks-table th,
.feedbacks-table td {
    height: 56px;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.feedbacks-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.feedbacks-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.feedbacks-table th.sortable:hover {
    background: var(--gray-100);
}

.feedbacks-table th.sortable .sort-icon {
    margin-left: 6px;
    opacity: 0.3;
}

.feedbacks-table th.sortable.asc .sort-icon::after {
    content: "▲";
    opacity: 1;
}

.feedbacks-table th.sortable.desc .sort-icon::after {
    content: "▼";
    opacity: 1;
}

.feedbacks-table tbody tr {
    transition: background 0.2s ease;
}

.feedbacks-table tbody tr:hover {
    background: var(--gray-50);
}

.feedbacks-table tbody tr.hidden {
    display: none;
}

/* Cell styles */
.cell-reference {
    font-family: monospace;
    font-weight: 500;
}

.cell-reference a,
.cell-title a {
    color: var(--primary-color);
    text-decoration: none;
}

.cell-reference a:hover,
.cell-title a:hover {
    text-decoration: underline;
}

.cell-title {
    max-width: 300px;
}

.cell-title a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-date {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Action badges */
.action-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-small);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.action-badge.configuration {
    background: #e3f2fd;
    color: #1565c0;
}

.action-badge.vendorRequest {
    background: #fff3e0;
    color: #e65100;
}

.action-badge.postponed {
    background: #f3e5f5;
    color: #7b1fa2;
}

.action-badge.abandoned {
    background: #ffebee;
    color: #c62828;
}

.action-badge.outOfScope {
    background: #eceff1;
    color: #546e7a;
}

.action-badge.duplicate {
    background: #fce4ec;
    color: #ad1457;
}

.action-badge.toBeClarified {
    background: #fff8e1;
    color: #ff8f00;
}

.action-badge.undecided {
    background: var(--gray-100);
    color: var(--text-secondary);
}

/* No results message */
.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Admin responsive */
@media (max-width: 768px) {
    .users-table-container,
    .feedbacks-table-container {
        overflow-x: auto;
    }

    .users-table,
    .feedbacks-table {
        min-width: 700px;
    }

    .modal-content {
        width: 95%;
    }

    .action-buttons {
        flex-direction: column;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-select,
    .filter-input {
        width: 100%;
    }

    .btn-reset {
        align-self: stretch;
    }
}

/* ===========================================
   Dark Mode
   =========================================== */
@media (prefers-color-scheme: dark) {
    /* Modal overlay */
    .overlay {
        background: rgba(0, 0, 0, 0.7);
    }

    /* Action badges dark mode */
    .action-badge.configuration {
        background: rgba(10, 132, 255, 0.2);
        color: #64B5F6;
    }

    .action-badge.vendorRequest {
        background: rgba(255, 159, 10, 0.2);
        color: #FFB74D;
    }

    .action-badge.postponed {
        background: rgba(125, 122, 255, 0.2);
        color: #B388FF;
    }

    .action-badge.abandoned {
        background: rgba(255, 69, 58, 0.2);
        color: #EF9A9A;
    }

    .action-badge.outOfScope {
        background: rgba(142, 142, 147, 0.2);
        color: #AEAEB2;
    }

    .action-badge.duplicate {
        background: rgba(236, 64, 122, 0.2);
        color: #F48FB1;
    }

    .action-badge.toBeClarified {
        background: rgba(255, 214, 10, 0.2);
        color: #FFD54F;
    }
}

/* ===========================================
   Tags Management
   =========================================== */

.create-tag-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 32px;
}

.create-tag-form h3 {
    margin-top: 0;
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
}

.form-row .form-group.form-actions {
    flex: 0;
}

.form-actions-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    cursor: pointer;
    background: var(--background);
}

.tags-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.tags-list h3 {
    margin-top: 0;
    margin-bottom: 20px;
}

.tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tag-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.tag-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: var(--radius-small);
    font-size: 0.875rem;
    font-weight: 500;
    background-color: #e5e7eb;
    color: #4b5563;
}

.tag-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tag-actions .inline-form {
    display: inline;
}

.empty-message {
    color: var(--text-secondary);
    font-style: italic;
}

/* Tags on feedback detail */
.feedback-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.feedback-tags .tag-badge {
    font-size: 0.8rem;
    padding: 4px 10px;
}

.tags-form {
    margin-top: 20px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-small);
}

.tags-form h4 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tags-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.tags-checkboxes label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.tags-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
    .tags-form {
        background: var(--gray-800);
    }

    .tag-badge,
    .feedback-tags .tag-badge,
    .cell-tags .tag-badge,
    .tag-preview,
    .tags-autocomplete-container .selected-tag,
    .tags-autocomplete-container .tag-preview {
        background-color: #374151;
        color: #d1d5db;
    }

    .tag-remove,
    .tags-autocomplete-container .tag-remove-btn {
        color: #9ca3af;
    }

    .tag-remove:hover,
    .tags-autocomplete-container .tag-remove-btn:hover {
        color: #e5e7eb;
    }
}

/* ===========================================
   Tags Autocomplete
   =========================================== */

.tags-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.tags-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-add-tag {
    background: var(--gray-100);
    border: 1px dashed var(--border);
    border-radius: var(--radius-small);
    padding: 4px 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-tag:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    border-style: solid;
}

.feedback-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.feedback-tags .tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--radius-small);
    font-size: 0.8rem;
    font-weight: 500;
    background-color: #e5e7eb;
    color: #4b5563;
    transition: all 0.2s ease;
}

.tag-remove {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    line-height: 1;
    transition: color 0.2s ease;
}

.tag-remove:hover {
    color: #374151;
}

.tag-autocomplete {
    position: relative;
    margin-top: 12px;
}

.tag-autocomplete input {
    width: 100%;
    max-width: 300px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 0.9rem;
    background: var(--background);
    transition: all 0.2s ease;
}

.tag-autocomplete input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-width: 300px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-small) var(--radius-small);
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 100;
}

.tag-suggestion {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.tag-suggestion:hover {
    background: var(--gray-50);
}

.tag-preview {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-small);
    font-size: 0.8rem;
    font-weight: 500;
    background-color: #e5e7eb;
    color: #4b5563;
}

.no-suggestions {
    padding: 12px 14px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
    .btn-add-tag {
        background: var(--gray-800);
    }

    .tag-suggestion:hover {
        background: var(--gray-800);
    }
}

/* ===========================================
   Tags Autocomplete in Forms
   =========================================== */

.tags-autocomplete-container {
    position: relative;
}

.tags-autocomplete-container .selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.tags-autocomplete-container .selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--radius-small);
    font-size: 0.85rem;
    font-weight: 500;
    background-color: #e5e7eb;
    color: #4b5563;
}

.tags-autocomplete-container .tag-remove-btn {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    line-height: 1;
    transition: color 0.2s ease;
}

.tags-autocomplete-container .tag-remove-btn:hover {
    color: #374151;
}

.tags-autocomplete-container .tag-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 0.9rem;
    background: var(--background);
    transition: all 0.2s ease;
}

.tags-autocomplete-container .tag-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.tags-autocomplete-container .tag-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-small) var(--radius-small);
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 100;
}

.tags-autocomplete-container .tag-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.tags-autocomplete-container .tag-dropdown-item:hover {
    background: var(--gray-50);
}

.tags-autocomplete-container .tag-dropdown-empty {
    padding: 12px 14px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
}

.tags-autocomplete-container .tag-preview {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-small);
    font-size: 0.85rem;
    font-weight: 500;
    background-color: #e5e7eb;
    color: #4b5563;
}

.tags-autocomplete-container .hidden-tag-inputs {
    display: none;
}

@media (prefers-color-scheme: dark) {
    .tags-autocomplete-container .tag-dropdown-item:hover {
        background: var(--gray-800);
    }
}

/* Tag badges in feedback table */
.cell-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.cell-tags .tag-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-small);
    font-size: 0.75rem;
    font-weight: 500;
    background-color: #e5e7eb;
    color: #4b5563;
    white-space: nowrap;
}

/* ===========================================
   Unread Feedback Indicator
   =========================================== */

.feedback-row.unread {
    background-color: rgba(0, 122, 255, 0.04);
}

.feedback-row.unread .cell-reference a,
.feedback-row.unread .cell-title a {
    font-weight: 700;
    color: var(--text-primary);
}

.feedback-row.unread:hover {
    background-color: rgba(0, 122, 255, 0.08);
}

/* Indicateur visuel (petit point bleu) */
.feedback-row.unread .cell-reference::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

@media (prefers-color-scheme: dark) {
    .feedback-row.unread {
        background-color: rgba(10, 132, 255, 0.1);
    }

    .feedback-row.unread .cell-reference a,
    .feedback-row.unread .cell-title a {
        color: var(--primary-color);
    }
}
