﻿/* Welcome Section */
.welcome-section {
    background: linear-gradient(135deg, var(--primary) 0%, #4752C4 100%);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    text-align: center;
}

.welcome-section h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
}

/* Service Status Card */
.service-status-card {
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.service-status-card .service-card-body {
    padding: 1rem 0;
    text-align: center;
}

.service-status-card .service-card-body p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.service-card {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.service-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.service-status-header,
.service-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-light);
}

.service-card-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.service-badge {
    padding: 0.625rem 1.25rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    background: #5865F2;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.service-badge.on-duty,
.service-badge.active {
    background: linear-gradient(135deg, #10b981, #059669);
    animation: pulse-badge 2s infinite;
}

.service-badge.off-duty {
    background: #5865F2;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.service-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.btn-primary,
.btn-service {
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #4c51bf);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover,
.btn-service:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:active,
.btn-service:active {
    transform: translateY(0);
    background: linear-gradient(135deg, var(--primary), #4c51bf);
}

.btn-primary:focus,
.btn-service:focus {
    outline: none;
    background: linear-gradient(135deg, var(--primary), #4c51bf);
}

.btn-primary.discord-blue-btn,
.btn-service.discord-blue-btn {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 18px rgba(114, 137, 218, 0.35);
}

.btn-primary.discord-blue-btn:hover,
.btn-service.discord-blue-btn:hover {
    background: #4752C4;
    box-shadow: 0 5px 18px rgba(114, 137, 218, 0.45);
}

.btn-primary.discord-blue-btn:active,
.btn-service.discord-blue-btn:active {
    background: var(--primary);
    box-shadow: 0 4px 18px rgba(114, 137, 218, 0.35);
}

.btn-primary.discord-blue-btn:focus,
.btn-service.discord-blue-btn:focus {
    outline: none;
    background: var(--primary);
    box-shadow: 0 4px 18px rgba(114, 137, 218, 0.35);
}

#create-certificat-modal .modal-header,
#create-evaluation-modal .modal-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #5865f2 0%, #4752c4 100%);
    color: white;
}

#create-certificat-modal .modal-header h3,
#create-evaluation-modal .modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

#create-certificat-modal .modal-header .modal-close,
#create-evaluation-modal .modal-header .modal-close {
    color: white;
    opacity: 0.9;
}

#create-certificat-modal > .modal-content,
#create-evaluation-modal > .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-secondary) !important;
}

#create-certificat-modal #create-certificat-form,
#create-evaluation-modal #create-evaluation-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-secondary);
}

#create-certificat-modal .modal-body,
#create-evaluation-modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 1rem;
    background: transparent;
}

#create-certificat-modal .modal-actions,
#create-evaluation-modal .modal-actions,
.cert-eval-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem 1.25rem 0.85rem !important;
    background: transparent !important;
    border-top: none !important;
    box-shadow: none !important;
    gap: 0.5rem;
    margin-top: 0 !important;
    margin-bottom: 0;
    flex-shrink: 0;
}

#create-certificat-modal .modal-actions .btn-primary,
#create-certificat-modal .modal-actions .btn-secondary,
#create-evaluation-modal .modal-actions .btn-primary,
#create-evaluation-modal .modal-actions .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.95rem !important;
    font-size: 0.875rem;
    line-height: 1;
    min-height: 2.25rem;
    width: auto;
    flex: 0 0 auto;
    gap: 0.35rem;
    vertical-align: middle;
    box-sizing: border-box;
}

#create-certificat-modal .modal-actions .btn-secondary,
#create-evaluation-modal .modal-actions .btn-secondary {
    border: 1px solid var(--border);
}

#create-certificat-modal .modal-actions .btn-primary,
#create-evaluation-modal .modal-actions .btn-primary {
    border: 1px solid transparent;
}

#create-certificat-modal .modal-actions .btn-primary i,
#create-certificat-modal .modal-actions .btn-secondary i,
#create-evaluation-modal .modal-actions .btn-primary i,
#create-evaluation-modal .modal-actions .btn-secondary i,
#create-certificat-modal .modal-actions .btn-primary svg,
#create-certificat-modal .modal-actions .btn-secondary svg,
#create-evaluation-modal .modal-actions .btn-primary svg,
#create-evaluation-modal .modal-actions .btn-secondary svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
}

.btn-primary,
.btn-service {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #4b5563, #374151);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.btn-danger {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-primary:hover,
.btn-service:hover {
    background: #4752C4;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(88, 101, 242, 0.4);
}

.btn-service.active {
    background: var(--danger);
}

.btn-service.active:hover {
    background: #c0392b;
}

/* Service Panel */
.service-panel {
    display: grid;
    gap: 2rem;
    margin-top: 1.5rem;
}

.service-card-body {
    padding: 2rem 1.5rem 1.5rem 1.5rem;
}

.service-card-body p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.service-time {
    background: rgba(87, 242, 135, 0.08);
    border: 1px solid rgba(87, 242, 135, 0.3);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.service-time-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.service-time-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
    font-family: 'Courier New', monospace;
}

/* EMS On Duty List */
.ems-on-duty-list {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.ems-on-duty-list:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ems-on-duty-list h4 {
    margin-bottom: 1.5rem;
    padding-bottom: 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 600;
}

/* Service List Section */
.service-list-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.service-list-section h4 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-primary);
}

/* Personnel en Service Card */
.personnel-on-duty-card {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.personnel-on-duty-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.personnel-on-duty-card .section-header {
    margin-bottom: 1.5rem;
}

.personnel-on-duty-card .section-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 600;
}

/* Mon Service Actuel */
.my-current-service {
    background: linear-gradient(135deg, rgba(88, 101, 242, 0.1), rgba(88, 101, 242, 0.05));
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.my-service-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.my-service-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.my-service-title i {
    width: 22px;
    height: 22px;
    color: var(--primary);
}

.my-service-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.my-service-detail {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.my-service-detail i {
    width: 18px;
    height: 18px;
    color: var(--primary);
    flex-shrink: 0;
}

.my-service-detail .detail-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.my-service-detail .detail-value {
    color: var(--text-primary);
    font-weight: 600;
    margin-left: auto;
}

.my-service-comment {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-dark);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.my-service-comment i {
    width: 18px;
    height: 18px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

.my-service-comment span {
    color: var(--text-primary);
    line-height: 1.5;
}

/* Tableau des services */
.services-table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.services-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-dark);
}

.services-table thead {
    background: var(--bg-darker);
    border-bottom: 2px solid var(--border);
}

.services-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    white-space: nowrap;
    border-right: 2px solid var(--border);
}

.services-table th:last-child {
    border-right: none;
}

.services-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.services-table tbody tr:hover {
    background: var(--bg-light);
}

.services-table td {
    padding: 1rem;
    color: var(--text-secondary);
    vertical-align: middle;
    border-right: 2px solid var(--border);
}

.services-table td:last-child {
    border-right: none;
}

.table-user-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.unit-group-separator td {
    padding: 0 !important;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--border) 15%, var(--border) 85%, transparent 100%);
    opacity: 0.5;
}

.shared-unit-cell {
    background: rgba(16, 185, 129, 0.08);
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.45);
}

.shared-unit-pill {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.5);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.table-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.table-username {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.table-rank {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.defib-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.defib-badge.yes {
    background: rgba(39, 174, 96, 0.2);
    color: var(--success);
}

.defib-badge.no {
    background: rgba(237, 66, 69, 0.2);
    color: var(--danger);
}

.time-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: rgba(88, 101, 242, 0.15);
    color: var(--primary);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.time-badge--live {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-width: 9.5rem;
    box-sizing: border-box;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    white-space: nowrap;
}

.service-time-part {
    display: inline-block;
    text-align: center;
}

.service-time-part--days {
    min-width: 1.6rem;
}

.service-time-part--hours {
    min-width: 2rem;
}

.service-time-part--minutes {
    min-width: 2.6rem;
}

.service-time-part--seconds {
    min-width: 2.4rem;
}

.table-comment {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-btn {
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.table-btn i {
    width: 18px;
    height: 18px;
}

.table-btn.btn-join {
    background: rgba(39, 174, 96, 0.2);
    color: var(--success);
}

.table-btn.btn-join:hover:not(:disabled) {
    background: rgba(39, 174, 96, 0.3);
    transform: translateY(-2px);
}

.table-btn.btn-join.disabled,
.table-btn.btn-join:disabled {
    background: rgba(116, 127, 141, 0.15);
    color: #747F8D;
    cursor: not-allowed;
    opacity: 0.5;
}

.table-btn.btn-copy {
    background: rgba(88, 101, 242, 0.2);
    color: #8ea1ff;
}

.table-btn.btn-copy:hover {
    background: rgba(88, 101, 242, 0.3);
    transform: translateY(-2px);
}

.table-btn.btn-force-end {
    background: rgba(237, 66, 69, 0.2);
    color: var(--danger);
}

.table-btn.btn-force-end:hover {
    background: rgba(237, 66, 69, 0.3);
    transform: translateY(-2px);
}

/* Ligne de l'utilisateur actuel */
.current-user-row {
    background: rgba(88, 101, 242, 0.08);
}

.current-user-row:hover {
    background: rgba(88, 101, 242, 0.12) !important;
}

.you-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Service Hours Statistics */
.service-hours-section {
    margin-top: 2rem;
}

.service-hours-section .section-header {
    margin-bottom: 1.5rem;
}

.service-hours-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.stat-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border-radius: 10px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.recent-services {
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.recent-services h4 {
    margin-bottom: 1.25rem;
    font-size: 1.05rem;
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recent-services-list {
    display: block;
    width: 100%;
}

.service-history-item {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.service-history-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(180deg, var(--primary-color), var(--primary-dark));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.service-history-item:hover {
    background: var(--bg-dark);
    border-color: var(--primary-color);
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.service-history-item:hover::before {
    opacity: 1;
}

.service-history-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.service-history-date {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

.service-history-location {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.service-history-time {
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    opacity: 0.9;
}

.service-history-details {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    padding-left: 0.25rem;
}

.service-history-details span {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.service-history-item:hover .service-history-details span {
    opacity: 1;
}

.service-history-duration {
    display: flex;
    align-items: center;
    margin-left: 1rem;
}

.duration-badge {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
    letter-spacing: 0.02em;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.service-history-item:hover .duration-badge {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    transform: scale(1.05);
}

/* ============================================
   NOUVEAU DESIGN TIMELINE HISTORIQUE
   ============================================ */

.timeline-item {
    position: relative;
    padding-left: 2.5rem;
    padding-bottom: 1.5rem;
    opacity: 0;
    animation: slideIn 0.4s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    z-index: 2;
}

.timeline-item:not(:last-child) .timeline-marker::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    width: 2px;
    height: calc(100% + 1.5rem);
    background: linear-gradient(180deg, var(--border), transparent);
    transform: translateX(-50%);
}

.timeline-content {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.timeline-content:hover {
    border-color: var(--primary-color);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.12);
    transform: translateX(4px);
}

.timeline-header {
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.timeline-date {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.date-text {
    letter-spacing: -0.01em;
}

.timeline-duration {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
    letter-spacing: 0.02em;
}

.timeline-body {
    padding: 1.25rem;
}

.timeline-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border);
}

.timeline-time strong {
    color: var(--primary-color);
    font-weight: 600;
}

.timeline-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.5rem;
    background: var(--bg-darker);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.detail-item:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
    transform: translateX(4px);
}

.detail-item i {
    color: var(--primary-color);
    flex-shrink: 0;
}

.detail-item span {
    flex: 1;
    font-weight: 500;
}

/* ============================================
   CARDS EMS MODERNES
   ============================================ */

.ems-card-modern {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    animation: slideIn 0.4s ease forwards;
}

.ems-card-modern:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.15);
    transform: translateY(-4px);
}

.ems-card-header {
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.ems-avatar-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.ems-card-info {
    flex: 1;
}

.ems-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.ems-card-rank {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.ems-status-badge {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-pulse {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
}

.ems-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.65rem;
    background: var(--bg-darker);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.info-row:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
    transform: translateX(4px);
}

.info-row i {
    color: var(--primary-color);
    flex-shrink: 0;
}

.info-row span {
    font-weight: 500;
}

.time-row {
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.2);
    font-weight: 600;
    color: var(--primary-color);
}

.ems-card-footer {
    padding: 1rem 1.25rem;
    background: var(--bg-darker);
    border-top: 1px solid var(--border);
}

.btn-join-unit {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-join-unit:hover {
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    transform: translateY(-2px);
}

.service-history-duration {
    font-weight: 600;
    color: var(--success);
    font-size: 1rem;
}

.ems-service-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.ems-service-name {
    font-weight: 500;
    font-size: 0.875rem;
}

/* Info Cards */
.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.info-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: start;
}

.info-card-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.info-card-content h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.info-card-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.optimization-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    background: linear-gradient(90deg, #fffbeb, #fef3c7);
    border: 1px solid #fde68a;
    color: #92400e;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.12);
    font-weight: 600;
    margin-bottom: 1rem;
}

.optimization-banner strong {
    color: #92400e;
}

/* Service Recap Section (Admin Overview) */
.service-recap-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.service-recap-section .section-header {
    margin-bottom: 1.5rem;
}

.service-recap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.recap-card {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.recap-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(103, 58, 183, 0.2);
}

.recap-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border-radius: 10px;
}

.recap-content {
    flex: 1;
}

.recap-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.recap-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.top-ems-section {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.top-ems-section h4 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.top-ems-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.top-ems-item {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: background 0.2s ease;
}

.top-ems-item:hover {
    background: var(--bg-dark);
}

.top-ems-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 35px;
    text-align: center;
}

.top-ems-rank.rank-1 { color: #FFD700; }
.top-ems-rank.rank-2 { color: #C0C0C0; }
.top-ems-rank.rank-3 { color: #CD7F32; }

.top-ems-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.top-ems-info {
    flex: 1;
}

.top-ems-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.top-ems-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.top-ems-hours {
    font-weight: 600;
    color: var(--success);
    font-size: 1.1rem;
}

/* Responsive service page fixes */
.service-panel {
    grid-template-columns: minmax(260px, 0.42fr) minmax(0, 1fr);
    align-items: start;
    max-width: 100%;
    min-width: 0;
}

.service-sidebox,
.ems-on-duty-list,
#ems-on-duty-list-content,
.services-table-container {
    min-width: 0;
    max-width: 100%;
}

#ems-on-duty-list-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 1rem;
}

.ems-card {
    min-width: 0;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

.ems-card-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.ems-card-info,
.ems-name,
.ems-rank,
.service-detail,
.detail-value {
    min-width: 0;
}

.ems-name,
.detail-value {
    overflow-wrap: anywhere;
}

.ems-card .service-badge {
    white-space: nowrap;
    padding: 0.45rem 0.75rem;
    font-size: 0.78rem;
}

.ems-card-details {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
}

.ems-card .service-detail {
    display: grid;
    grid-template-columns: auto minmax(88px, auto) minmax(0, 1fr);
    align-items: start;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.ems-card .detail-icon svg {
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.ems-card .detail-label {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.ems-card .detail-value {
    color: var(--text-primary);
    text-align: right;
}

.services-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.services-table {
    table-layout: auto;
    min-width: 1320px;
}

.services-table th,
.services-table td {
    padding: 0.85rem 1rem;
    white-space: nowrap;
    overflow-wrap: normal;
}

.services-table th:nth-child(1),
.services-table td:nth-child(1) {
    min-width: 190px;
}

.services-table th:nth-child(2),
.services-table td:nth-child(2),
.services-table th:nth-child(3),
.services-table td:nth-child(3) {
    min-width: 135px;
}

.services-table th:nth-child(4),
.services-table td:nth-child(4),
.services-table th:nth-child(5),
.services-table td:nth-child(5),
.services-table th:nth-child(6),
.services-table td:nth-child(6),
.services-table th:nth-child(7),
.services-table td:nth-child(7) {
    min-width: 120px;
}

.services-table th:nth-child(8),
.services-table td:nth-child(8),
.services-table th:nth-child(9),
.services-table td:nth-child(9) {
    min-width: 95px;
}

.services-table th:nth-child(10),
.services-table td:nth-child(10) {
    min-width: 170px;
}

.services-table th:nth-child(11),
.services-table td:nth-child(11) {
    min-width: 90px;
}

.table-user-cell {
    min-width: 160px;
}

.table-comment {
    max-width: 260px;
    white-space: nowrap;
}

@media (max-width: 1180px) {
    .service-panel {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .service-sidebox,
    .ems-on-duty-list {
        width: 100%;
        height: auto;
    }
}

@media (max-width: 760px) {
    .service-panel {
        margin-top: 1rem;
    }

    .service-sidebox,
    .ems-on-duty-list {
        padding: 1rem;
        border-radius: 10px;
    }

    .service-sidebox-header {
        margin: -1rem -1rem 1rem;
        border-radius: 10px 10px 0 0;
    }

    .ems-card-header {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .ems-card .service-badge {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .ems-card .service-detail {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .ems-card .detail-label {
        display: none;
    }

    .ems-card .detail-value {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .services-table-container {
        border: 0;
        overflow: visible;
    }

    .services-table,
    .services-table thead,
    .services-table tbody,
    .services-table tr,
    .services-table th,
    .services-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .services-table thead {
        display: none;
    }

    .services-table {
        background: transparent;
        border-collapse: separate;
        border-spacing: 0;
    }

    .services-table tbody tr {
        background: var(--bg-dark);
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 0.9rem;
        overflow: hidden;
    }

    .services-table tbody tr.unit-group-separator {
        display: none;
    }

    .services-table td {
        display: grid;
        grid-template-columns: minmax(90px, 0.42fr) minmax(0, 1fr);
        gap: 0.75rem;
        padding: 0.75rem 0.9rem;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .services-table td:last-child {
        border-bottom: 0;
    }

    .services-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.78rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .services-table td.onduty-cell-empty {
        display: none;
    }

    .table-user-cell,
    .table-actions {
        min-width: 0;
        justify-content: flex-start;
    }
}

.services-table td.onduty-cell-empty {
    padding: 0;
    border: 0;
    width: 0;
    max-width: 0;
    overflow: hidden;
}

.service-preset-chips {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.service-sidebox .service-preset-chip {
    width: auto !important;
    max-width: none;
    flex: 0 0 auto;
    margin-top: 0 !important;
    padding: 0.16rem 0.42rem;
    font-size: 0.68rem;
    font-weight: 500;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
    line-height: 1.2;
    white-space: nowrap;
    grid-column: auto !important;
}

.service-sidebox .service-preset-chip:hover {
    border-color: rgba(88, 101, 242, 0.65);
    color: var(--text-primary);
    background: rgba(88, 101, 242, 0.12);
}

.service-sidebox .service-preset-chip.active {
    border-color: var(--primary);
    background: rgba(88, 101, 242, 0.24);
    color: #fff;
}

.service-sidebox .service-comment-counter {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 0.2rem;
    line-height: 1;
}

.service-sidebox .service-comment-counter.char-counter--limit {
    color: var(--danger);
}

