/* Setup Database Styles */

.setup-database-app {
    min-height: 100vh;
    background: var(--color-background);
    padding-top: 80px; /* Hauteur navbar */
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--color-border);
}

.page-title-section {
    flex: 1;
}

.page-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-2) 0;
}

.page-title i {
    color: var(--color-primary);
}

.page-subtitle {
    color: var(--color-text-secondary);
    font-size: var(--font-size-lg);
    margin: 0;
}

.page-actions {
    display: flex;
    gap: var(--space-3);
}

/* Filters Section */
.filters-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 150px;
}

.filter-group label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
}

.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.search-input {
    padding-left: 32px;
    text-indent: 20px;
}

.search-input::placeholder {
    text-indent: 20px;
}

.filter-actions {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

.filter-actions .btn {
    padding: 6px 12px;
    font-size: var(--font-size-xs);
}

.filter-actions .btn i {
    width: 14px;
    height: 14px;
}

/* Table Section */
.table-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.table-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin: 0;
}

.table-info {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.table-container {
    overflow-x: auto;
}

/* Setups Table */
.setups-table {
    width: 100%;
    border-collapse: collapse;
}

.setups-table th {
    background: var(--color-background);
    padding: var(--space-4);
    text-align: left;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.setups-table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
}

.setups-table tbody tr:hover {
    background: var(--color-background);
}

/* Table Cell Types */
.circuit-cell {
    min-width: 180px;
}

.circuit-name {
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
}

.circuit-variant {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    display: block;
}

.car-cell {
    min-width: 160px;
}

.car-name {
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
}

.car-category {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    display: block;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
}

.type-badge.fixed {
    background: rgba(99, 102, 241, 0.1);
    color: #6366F1;
}

.type-badge.open {
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
}

.session-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
}

.session-badge.qualifying {
    background: rgba(245, 158, 11, 0.1);
    color: #F59E0B;
}

.session-badge.race {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

.session-badge.practice {
    background: rgba(107, 114, 128, 0.1);
    color: #6B7280;
}

.session-badge i {
    width: 12px;
    height: 12px;
}

.lap-time {
    font-family: var(--font-mono);
    font-weight: var(--font-weight-medium);
    color: var(--color-primary);
}

.fuel-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fuel-amount {
    font-family: var(--font-mono);
    font-weight: var(--font-weight-medium);
}

.fuel-consumption {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.laps-count {
    font-family: var(--font-mono);
    font-weight: var(--font-weight-medium);
    color: var(--color-accent);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: var(--space-2);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: var(--font-size-sm);
}

.action-btn.edit {
    background: rgba(99, 102, 241, 0.1);
    color: #6366F1;
}

.action-btn.edit:hover {
    background: rgba(99, 102, 241, 0.2);
}

.action-btn.delete {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

.action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

.action-btn.duplicate {
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
}

.action-btn.duplicate:hover {
    background: rgba(16, 185, 129, 0.2);
}

.action-btn.view {
    background: rgba(59, 130, 246, 0.1);
    color: #3B82F6;
}

.action-btn.view:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.empty-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-background);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-4);
}

.empty-icon i {
    width: 32px;
    height: 32px;
    color: var(--color-text-tertiary);
}

.empty-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-2) 0;
}

.empty-description {
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-6) 0;
    max-width: 400px;
}

/* Setup Modal */
.setup-modal .modal-content {
    max-width: 1200px;
    width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}

/* Setup Details Modal */
.setup-details-modal .modal-content {
    max-width: 800px;
    width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}

.setup-modal-body {
    max-height: calc(90vh - 180px);
    overflow-y: auto;
}

.setup-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

/* Form Sections */
.form-section {
    padding: var(--space-6);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-4) 0;
}

.section-title i {
    color: var(--color-primary);
}

.form-row {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex: 1;
    min-width: 200px;
}

.form-group-small {
    flex: 0 0 120px;
    min-width: 120px;
}

.form-group label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
}

.form-control {
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    transition: all var(--transition-base);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(255, 30, 30, 0.1);
}

.form-control:disabled {
    background: var(--color-background);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
}

.form-control[readonly] {
    background: var(--color-background);
    color: var(--color-text-secondary);
}

/* Radio Groups */
.radio-group {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    transition: all var(--transition-base);
    min-width: 120px;
    justify-content: center;
}

.radio-option:hover {
    border-color: var(--color-primary);
    background: rgba(255, 30, 30, 0.05);
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-full);
    position: relative;
    transition: all var(--transition-base);
}

.radio-option input[type="radio"]:checked + .radio-custom {
    border-color: var(--color-primary);
}

.radio-option input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: var(--radius-full);
}

.radio-option input[type="radio"]:checked {
    & + .radio-custom + span {
        color: var(--color-primary);
        font-weight: var(--font-weight-semibold);
    }
}

.radio-option input[type="radio"]:checked ~ * {
    color: var(--color-primary);
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: var(--color-primary);
    background: rgba(255, 30, 30, 0.1);
    color: var(--color-primary);
}

/* Parameter Groups */
.parameter-group {
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.parameter-title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-3) 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: var(--space-4);
        align-items: stretch;
    }

    .filters-row {
        flex-direction: column;
    }

    .filter-group {
        min-width: auto;
    }

    .filter-actions {
        margin-left: 0;
        justify-content: stretch;
    }

    .filter-actions .btn {
        flex: 1;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group,
    .form-group-small {
        min-width: auto;
        flex: none;
    }

    .radio-group {
        flex-direction: column;
        gap: var(--space-2);
    }

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

    .setups-table {
        font-size: var(--font-size-xs);
    }

    .setups-table th,
    .setups-table td {
        padding: var(--space-2);
    }
}

@media (max-width: 480px) {
    .setup-database-app {
        padding-top: 70px;
    }

    .container {
        padding: 0 var(--space-4);
    }

    .page-title {
        font-size: var(--font-size-xl);
    }

    .setup-modal .modal-content {
        margin: var(--space-4);
        max-width: calc(100vw - 32px);
    }

    .table-container {
        margin: 0 calc(-1 * var(--space-4));
    }
}

/* Animation pour les filtres */
.filters-section {
    animation: slideDown 0.3s ease-out;
}

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

/* Hover effects */
.setups-table tbody tr {
    transition: background-color var(--transition-base);
}

.btn {
    transition: all var(--transition-base);
}

.btn:hover {
    transform: translateY(-1px);
}

/* Focus styles for accessibility */
.form-control:focus,
.btn:focus,
.action-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 30, 30, 0.1);
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top: 2px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Setup Details Modal - New Layout */
.setup-details-header {
    padding: var(--space-4) 0 var(--space-6) 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-6);
}

.setup-header-info {
    text-align: left;
}

.circuit-name {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-2) 0;
}

.car-name {
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-3) 0;
}

.setup-badges {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.setup-details-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.parameters-section,
.fuel-section,
.performance-section,
.notes-section {
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.parameters-section h3,
.fuel-section h3,
.performance-section h3,
.notes-section h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-4) 0;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

.parameters-section h3 i,
.fuel-section h3 i,
.performance-section h3 i,
.notes-section h3 i {
    color: var(--color-primary);
    width: 16px;
    height: 16px;
}

/* Parameters Table */
.parameters-table {
    width: 100%;
    border-collapse: collapse;
}

.parameters-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.parameters-table td:last-child {
    border-right: none;
}

.param-label {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    width: 25%;
}

.param-value {
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    width: 25%;
}

.param-value.lap-time {
    font-family: var(--font-mono);
    color: var(--color-primary);
}

/* Notes Section */
.notes-content p {
    margin: 0;
    color: var(--color-text-primary);
    line-height: 1.5;
}

/* Fuel Calculator */
.fuel-calculator-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-top: var(--space-6);
}

.fuel-calculator-section h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-4) 0;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

.fuel-calculator-section h3 i {
    color: var(--color-primary);
    width: 16px;
    height: 16px;
}

.calculator-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: nowrap;
    padding: var(--space-3);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    min-width: 0; /* Allow flex items to shrink */
}

.calculator-content:last-child {
    margin-bottom: 0;
}

.duration-calculator {
    background: rgba(59, 130, 246, 0.05);
    border-color: rgba(59, 130, 246, 0.2);
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
}

.duration-calculator .calculator-input,
.duration-calculator .calculator-result {
    margin: 0 !important;
}

.calculator-input {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.calculator-input label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.calculator-input .form-control {
    width: 80px;
    padding: var(--space-2) var(--space-3);
}

.duration-unit {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
    margin-left: var(--space-1);
}

.calculator-result {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2);
    background: var(--color-background);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    white-space: nowrap;
    flex-shrink: 0;
    font-size: var(--font-size-sm);
}

.calculator-result span {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.calculator-result strong {
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
}

.calculator-info {
    color: var(--color-text-tertiary);
    font-size: var(--font-size-xs);
}

/* Single-line layout for duration calculator */
.duration-calculator .calculator-info {
    position: absolute;
    bottom: -20px;
    left: 0;
    margin: 0;
    font-size: var(--font-size-xs);
}

.duration-calculator {
    position: relative;
    margin-bottom: var(--space-6) !important;
}

@media (max-width: 900px) {
    .calculator-content {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
        flex-wrap: wrap;
    }
    
    .calculator-input {
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .setup-details-modal .modal-content {
        max-width: calc(100vw - 32px);
        margin: var(--space-4);
    }
    
    .parameters-table td {
        padding: var(--space-1) var(--space-2);
    }
    
    .param-label,
    .param-value {
        font-size: var(--font-size-xs);
    }
}

/* ========================================
   CONNECTION STATUS STYLES
   ======================================== */

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-surface-lighter);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-sm);
}

.connection-status.online {
    border-color: var(--color-success);
    background: rgba(16, 185, 129, 0.1);
}

.connection-status.offline {
    border-color: var(--color-warning);
    background: rgba(251, 191, 36, 0.1);
}

.status-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.status-icon.online {
    color: var(--color-success);
}

.status-icon.offline {
    color: var(--color-warning);
}

.migrate-btn {
    background: var(--color-primary);
    border: none;
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    transition: all 0.2s ease;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.migrate-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.migrate-btn i {
    width: 12px;
    height: 12px;
}

/* Connection status mobile styles */
@media (max-width: 768px) {
    .connection-status {
        font-size: var(--font-size-xs);
        padding: var(--space-2);
        gap: var(--space-1);
        flex-wrap: wrap;
    }
    
    .migrate-btn {
        font-size: var(--font-size-xs);
        padding: var(--space-1);
    }
}

/* Success Button Style */
.btn-success {
    background: #059669;
    color: white;
    border: 1px solid #059669;
}

.btn-success:hover {
    background: #047857;
    border-color: #047857;
    color: white;
}