/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 0;
    margin: 0;
    background: linear-gradient(135deg, #ecf0f1 0%, #bdc3c7 100%);
    min-height: 100vh;
}

/* Navigation */
.navbar {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    padding: 1rem 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand:hover {
    color: rgba(255,255,255,0.9);
}

.navbar-menu {
    display: flex;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-menu li {
    margin: 0;
}

.navbar-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: inline-block;
    font-weight: 500;
}

.navbar-link:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.navbar-link.active {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* Breadcrumbs */
.breadcrumbs {
    background: white;
    padding: 1rem 2rem;
    margin-bottom: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.breadcrumbs-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breadcrumb-link {
    color: #546e7a;
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb-link:hover {
    color: #34495e;
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #ccc;
}

.breadcrumb-current {
    color: #333;
    font-weight: 500;
}

/* Main content wrapper */
.main-wrapper {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.container {
    background-color: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 2rem;
}

h1 {
    color: #333;
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, #546e7a 0%, #34495e 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 73, 94, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 73, 94, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.5);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
}

.btn:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideInDown 0.4s ease;
    position: relative;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.alert.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

.alert-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
    font-weight: 500;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.alert-close:hover {
    opacity: 1;
    background: rgba(0,0,0,0.1);
}

.alert-success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border-left: 5px solid #28a745;
}

.alert-error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border-left: 5px solid #dc3545;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    color: #856404;
    border-left: 5px solid #ffc107;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
    border-left: 5px solid #17a2b8;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

table th, table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
    transition: all 0.3s ease;
}

table th {
    background: linear-gradient(135deg, #546e7a 0%, #34495e 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

table tbody tr {
    transition: all 0.3s ease;
}

table tbody tr:hover {
    background-color: #f8f9fa;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(84, 110, 122, 0.15);
}

table th a.sort-link {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    padding: 0.25rem 0.5rem;
    border-radius: 5px;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

table th a.sort-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

table th a.sort-link.active {
    color: white;
}

.sort-icon {
    opacity: 0.4;
    font-size: 0.85rem;
    line-height: 1;
}

table th a.sort-link:hover .sort-icon {
    opacity: 0.7;
}

table th a.sort-link.active .sort-icon {
    opacity: 1;
}

.filter-row th {
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.filter-row .btn {
    margin-right: 5px;
    white-space: nowrap;
}

/* Forms */
.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: #546e7a;
    box-shadow: 0 0 0 4px rgba(84, 110, 122, 0.1);
    transform: translateY(-2px);
}

.filter-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.3s ease;
}

.filter-input:focus {
    outline: none;
    border-color: #546e7a;
    box-shadow: 0 0 0 3px rgba(84, 110, 122, 0.15);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

.form-help {
    display: block;
    margin-top: 5px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

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

.form-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.char-counter {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: #999;
    margin-top: 3px;
}

.char-counter.warning {
    color: #ffc107;
}

.char-counter.danger {
    color: #dc3545;
    font-weight: 600;
}

.actions {
    margin-top: 20px;
}

.actions a {
    margin-right: 10px;
}

/* Diff Viewer Styles */
.view-toggle {
    margin: 20px 0;
    display: flex;
    gap: 10px;
}

.btn-toggle {
    padding: 10px 20px;
    border: 2px solid #007bff;
    background-color: white;
    color: #007bff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-toggle:hover {
    background-color: #f0f8ff;
}

.btn-toggle.active {
    background-color: #007bff;
    color: white;
}

.diff-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.diff-section-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.diff-content {
    line-height: 1.8;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.diff-deleted {
    background-color: #ffe6e6;
    color: #d32f2f;
    text-decoration: line-through;
    padding: 2px 4px;
}

.diff-added {
    background-color: #e6ffe6;
    color: #2e7d32;
    font-weight: bold;
    padding: 2px 4px;
}

.metadata-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e9ecef;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 9998;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: scaleIn 0.3s ease;
    position: relative;
    z-index: 9999;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-icon {
    font-size: 3rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.modal-body {
    color: #666;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.modal-footer .btn {
    min-width: 120px;
}

/* Dashboard Styles */
.dashboard-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.dashboard-header h1 {
    color: #34495e;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #546e7a 0%, #34495e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-header p {
    color: #666;
    font-size: 1.2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--card-color-1), var(--card-color-2));
}

.stat-card.total {
    --card-color-1: #546e7a;
    --card-color-2: #34495e;
}

.stat-card.remplacement {
    --card-color-1: #95a5a6;
    --card-color-2: #7f8c8d;
}

.stat-card.maillage {
    --card-color-1: #607d8b;
    --card-color-2: #455a64;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--card-color-1), var(--card-color-2));
}

.stat-value {
    font-size: 3rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #666;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #eee;
}

.panel-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

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

.records-table th {
    text-align: left;
    padding: 0.75rem;
    background: #f8f9fa;
    color: #666;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.records-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.records-table tr:hover {
    background: #f8f9fa;
}

.badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-remplacement {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.badge-maillage {
    background: linear-gradient(135deg, #607d8b, #455a64);
    color: white;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.category-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.category-name {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
}

.category-count {
    background: linear-gradient(135deg, #546e7a, #34495e);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 700;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #999;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.chart-bar {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-label {
    width: 120px;
    font-weight: 600;
    color: #333;
}

.chart-bar-container {
    flex: 1;
    height: 30px;
    background: #e9ecef;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #546e7a, #34495e);
    border-radius: 15px;
    transition: width 1s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
}

.id-link {
    color: #546e7a;
    text-decoration: none;
    font-weight: 600;
}

.id-link:hover {
    text-decoration: underline;
}

/* Duplicates Page Styles */
.duplicate-group {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-left: 5px solid;
}

.duplicate-group:nth-child(odd) {
    border-left-color: #546e7a;
}

.duplicate-group:nth-child(even) {
    border-left-color: #95a5a6;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #eee;
}

.group-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
}

.group-count {
    background: linear-gradient(135deg, #546e7a, #34495e);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 700;
}

.records-grid {
    display: grid;
    gap: 1rem;
}

.record-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1.5rem;
    position: relative;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.record-card:hover {
    border-color: #546e7a;
    transform: translateX(5px);
    background: #fff;
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.record-id {
    font-size: 1.2rem;
    font-weight: 700;
    color: #546e7a;
}

.record-date {
    font-size: 0.9rem;
    color: #666;
}

.record-content {
    display: grid;
    gap: 0.75rem;
}

.record-field {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1rem;
}

.field-label {
    font-weight: 600;
    color: #666;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-value {
    color: #333;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-back {
    background: rgba(255, 255, 255, 0.95);
    color: #546e7a;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    margin-bottom: 2rem;
    display: inline-block;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-back:hover {
    background: white;
    transform: translateY(-2px);
}

.btn-view {
    background: linear-gradient(135deg, #546e7a, #34495e);
    color: white;
    box-shadow: 0 4px 12px rgba(52, 73, 94, 0.3);
}

.btn-view:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 73, 94, 0.4);
}

.btn-edit {
    background: linear-gradient(135deg, #607d8b, #455a64);
    color: white;
    box-shadow: 0 4px 12px rgba(69, 90, 100, 0.3);
}

.btn-edit:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(69, 90, 100, 0.4);
}

/* Duplicate warning (for new/edit pages) */
.duplicate-warning {
    display: none;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.3);
    animation: slideDown 0.3s ease;
}

.duplicate-warning.show {
    display: block;
}

.duplicate-warning h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
}

.duplicate-warning p {
    margin: 0;
    opacity: 0.9;
}

.duplicate-warning a {
    color: white;
    text-decoration: underline;
    font-weight: bold;
}

.checking-indicator {
    display: none;
    color: #546e7a;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    font-weight: 500;
}

.checking-indicator.show {
    display: block;
}

/* Responsive */
@media (max-width: 968px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .view-toggle {
        flex-direction: column;
    }

    .btn-toggle {
        width: 100%;
    }

    .diff-card {
        padding: 15px;
    }

    .diff-content {
        font-size: 14px;
        max-height: 300px;
    }

    .navbar-menu {
        gap: 0.5rem;
    }

    .navbar-link {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .modal {
        width: 95%;
        padding: 1.5rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}
