/* Base Variables */
:root {
    --primary-color: #333;
    --secondary-color: #666;
    --light-gray: #f5f5f5;
    --medium-gray: #e0e0e0;
    --dark-gray: #999;
    --white: #ffffff;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --purple-color: #6f42c1;
    --orange-color: #fd7e14;
    --border-radius: 0.6rem;
    --box-shadow: 0 0.2rem 0.4rem rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* Container */
#angebot-table-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 2rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.4rem;
    line-height: 1.5;
    color: var(--primary-color);
}

/* Overview Statistics */
.angebot-overview {
    margin-bottom: 3rem;
}

.overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(30rem, 1fr));
    gap: 2rem;
}

.overview-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
    border-top: 0.4rem solid var(--primary-color);
}

.overview-card:nth-child(1) {
    border-top-color: var(--info-color);
}

.overview-card:nth-child(2) {
    border-top-color: var(--success-color);
}

.overview-card:nth-child(3) {
    border-top-color: var(--purple-color);
}

.overview-card h3 {
    margin: 0 0 1.5rem 0;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--primary-color);
}

.card-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1.5rem;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-number.offen {
    color: var(--warning-color);
}

.stat-number.amount {
    color: var(--success-color);
}

.stat-label {
    display: block;
    font-size: 1.2rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
}

/* Controls */
.angebot-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 2rem;
}

.search-container {
    flex: 1;
    max-width: 30rem;
}

.search-container input {
    width: 100%;
    padding: 0.4rem 1.5rem;
    border: 0.1rem solid var(--medium-gray);
    border-radius: var(--border-radius);
    font-size: 1.4rem;
    transition: var(--transition);
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(51, 51, 51, 0.1);
}

.filters-container {
    display: flex;
    gap: 1rem;
}

.filters-container select {
    padding: 0.4rem 1.5rem;
    border: 0.1rem solid var(--medium-gray);
    border-radius: var(--border-radius);
    font-size: 1.4rem;
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

.filters-container select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(51, 51, 51, 0.1);
}

/* Loading */
.loading-indicator {
    text-align: center;
    padding: 2rem;
}

.loading-indicator .spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 0.2rem solid var(--medium-gray);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Table */
.angebot-table-wrapper {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    margin-bottom: 2rem;
}

.angebot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.3rem;
}

.angebot-table.loading {
    opacity: 0.6;
    pointer-events: none;
}

.angebot-table th {
    background: var(--light-gray);
    padding: 1.5rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 0.1rem solid var(--medium-gray);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.angebot-table th:hover {
    background: var(--medium-gray);
}

.angebot-table th[data-sort]:after {
    content: '↕';
    position: absolute;
    right: 1rem;
    color: var(--dark-gray);
}

.angebot-table th.sorted-asc:after {
    content: '↑';
    color: var(--primary-color);
}

.angebot-table th.sorted-desc:after {
    content: '↓';
    color: var(--primary-color);
}

.angebot-table td {
    padding: 1.2rem 1rem;
    border-bottom: 0.1rem solid var(--light-gray);
    vertical-align: middle;
}

.angebot-table tbody tr {
    transition: var(--transition);
}

.angebot-table tbody tr:hover {
    background: var(--light-gray);
}

/* Badges */
.status-badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 0.4rem;
    font-size: 1.1rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.status-erstellt-nicht-versendet {
    background: rgba(23, 162, 184, 0.1);
    color: var(--info-color);
}

.status-badge.status-offen {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
}

.status-badge.status-zugesagt {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.status-badge.status-abgelehnt {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.8rem 1.6rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.3rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.btn-view {
    background: var(--primary-color);
    color: var(--white);
}

.btn-view:hover {
    background: #222;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: #222;
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--white);
}

.btn-secondary:hover {
    background: #555;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    color: var(--secondary-color);
    font-size: 1.3rem;
}

.pagination-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pagination-btn {
    padding: 0.8rem 1.2rem;
    border: 0.1rem solid var(--medium-gray);
    background: var(--white);
    color: var(--primary-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.3rem;
}

.pagination-btn:hover {
    background: var(--light-gray);
    border-color: var(--primary-color);
}

.pagination-btn.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.pagination-dots {
    padding: 0 0.5rem;
    color: var(--dark-gray);
}

/* Modal */
.angebot-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius);
    max-width: 80rem;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem;
    border-bottom: 0.1rem solid var(--medium-gray);
    background: var(--light-gray);
}

.modal-header h2 {
    margin: 0;
    font-size: 2rem;
    color: var(--primary-color);
}

.modal-close {
    font-size: 2.4rem;
    cursor: pointer;
    color: var(--dark-gray);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--primary-color);
}

.modal-body {
    padding: 2rem;
    max-height: calc(90vh - 10rem);
    overflow-y: auto;
}

.modal-section {
    margin-bottom: 2.5rem;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h3 {
    margin: 0 0 1.5rem 0;
    font-size: 1.6rem;
    color: var(--primary-color);
    border-bottom: 0.1rem solid var(--medium-gray);
    padding-bottom: 0.5rem;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));
    gap: 1.5rem;
}

.modal-field {
    display: flex;
    flex-direction: column;
}

.modal-field label {
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.modal-field span {
    font-size: 1.4rem;
    color: var(--primary-color);
}

.modal-field .amount-highlight {
    font-weight: 600;
    font-size: 1.6rem;
    color: var(--success-color);
}

.items-table {
    overflow-x: auto;
    margin-top: 1rem;
}

.items-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.2rem;
}

.items-table th,
.items-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 0.1rem solid var(--light-gray);
}

.items-table th {
    background: var(--light-gray);
    font-weight: 600;
    color: var(--primary-color);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 0.1rem solid var(--medium-gray);
}

.loading-content,
.error-content {
    text-align: center;
    padding: 3rem;
}

.loading-content .spinner {
    display: inline-block;
    width: 3rem;
    height: 3rem;
    border: 0.3rem solid var(--medium-gray);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

.error-content {
    color: var(--danger-color);
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* No results and error messages */
.no-results,
.error-message {
    text-align: center;
    padding: 3rem;
    color: var(--secondary-color);
    font-style: italic;
}

.error-message {
    color: var(--danger-color);
}

/* Table responsiveness */
.angebot-table-wrapper {
    overflow-x: auto;
    position: relative;
}

.angebot-table {
    min-width: 140rem;
}

.actions-column,
.actions {
    position: sticky;
    right: 0;
    background: var(--white);
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    min-width: 8rem;
}

.angebot-table tbody tr:hover .actions {
    background: var(--light-gray);
}

/* Column width optimizations */
.angebot-table th:nth-child(1),
.angebot-table td:nth-child(1) { width: 12rem; } /* Angebotsnummer */
.angebot-table th:nth-child(2),
.angebot-table td:nth-child(2) { min-width: 15rem; } /* Titel */
.angebot-table th:nth-child(3),
.angebot-table td:nth-child(3) { min-width: 12rem; } /* Kunde */
.angebot-table th:nth-child(4),
.angebot-table td:nth-child(4) { width: 8rem; } /* Datum */
.angebot-table th:nth-child(5),
.angebot-table td:nth-child(5) { width: 10rem; } /* Status */
.angebot-table th:nth-child(6),
.angebot-table td:nth-child(6) { width: 8rem; } /* Kategorie */
.angebot-table th:nth-child(7),
.angebot-table td:nth-child(7) { width: 8rem; } /* Netto */
.angebot-table th:nth-child(8),
.angebot-table td:nth-child(8) { width: 6rem; } /* Steuer */
.angebot-table th:nth-child(9),
.angebot-table td:nth-child(9) { width: 8rem; } /* Brutto */
.angebot-table th:nth-child(10),
.angebot-table td:nth-child(10) { width: 6rem; } /* Skonto */
.angebot-table th:nth-child(11),
.angebot-table td:nth-child(11) { width: 8rem; } /* Gültig bis */
.angebot-table th:nth-child(12),
.angebot-table td:nth-child(12) { width: 8rem; } /* Aktionen */

/* Responsive Design */
@media (max-width: 768px) {
    #angebot-table-container {
        padding: 1rem;
    }
    
    .angebot-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-container {
        max-width: none;
    }
    
    .filters-container {
        flex-wrap: wrap;
    }
    
    .filters-container select {
        flex: 1;
        min-width: 15rem;
    }
    
    .angebot-table-wrapper {
        overflow-x: auto;
    }
    
    .angebot-table {
        min-width: 160rem;
    }
    
    .pagination-container {
        flex-direction: column;
        text-align: center;
    }
    
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .modal-body {
        max-height: calc(100vh - 12rem);
    }
    
    .modal-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .overview-cards {
        grid-template-columns: 1fr;
    }
    
    .card-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

.btn-disabled {
    background: var(--light-gray);
    color: var(--dark-gray);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-disabled:hover {
    background: var(--light-gray);
    color: var(--dark-gray);
}

.empty-state {
    color: var(--secondary-color);
    font-style: italic;
    opacity: 0.8;
}