/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Navigation */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-title i {
    color: #f39c12;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover,
.nav-link.active {
    background-color: #34495e;
}

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

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

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

.page-header h2 {
    font-size: 2rem;
    color: #2c3e50;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.date-filter-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
}

.date-filter-controls select {
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 0.9rem;
}

.bulk-import-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
}

.bulk-import-status {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.import-progress {
    width: 100%;
    height: 20px;
    background-color: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.import-progress-bar {
    height: 100%;
    background-color: #3498db;
    transition: width 0.3s ease;
}

.import-log {
    max-height: 200px;
    overflow-y: auto;
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.import-result-success {
    color: #155724;
    background-color: #d4edda;
    padding: 0.25rem;
    margin: 0.1rem 0;
    border-radius: 2px;
}

.import-result-error {
    color: #721c24;
    background-color: #f8d7da;
    padding: 0.25rem;
    margin: 0.1rem 0;
    border-radius: 2px;
}

.total-cost {
    font-size: 1.2rem;
    font-weight: bold;
    color: #27ae60;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3 {
    margin-bottom: 0.5rem;
    color: #7f8c8d;
    font-size: 0.9rem;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.stat-card h3 i {
    font-size: 1.2rem;
    color: #3498db;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

.stat-unit {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.chart-container {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: 400px;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow-x: auto;
}

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

.data-table th {
    background-color: #34495e;
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

/* Date column width for Energie and Einnahmen tables */
.data-table th:first-child,
.data-table td:first-child {
    width: 120px;
    min-width: 120px;
    white-space: nowrap;
}

/* Energy row expandable details */
.energy-row:hover {
    background-color: #f8f9fa;
}

.expand-icon {
    margin-left: 8px;
    font-size: 0.8em;
    transition: transform 0.2s ease;
}

.energy-details-row {
    background-color: #f8f9fa;
}

.energy-details-panel {
    padding: 1rem;
    border-left: 3px solid #3498db;
    background-color: white;
    margin: 0.5rem;
    border-radius: 4px;
}

.tariff-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.tariff-detail-item {
    background-color: #ecf0f1;
    padding: 1rem;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.tariff-detail-item h4 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1rem;
}

.tariff-breakdown-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tariff-line {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid #d5dbdb;
}

.tariff-line:last-child {
    border-bottom: none;
}

.tariff-line span:first-child {
    font-weight: 500;
    color: #34495e;
}

.tariff-line span:last-child {
    font-weight: 600;
    color: #2c3e50;
}

.loading-message {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 1rem;
}

.error-message {
    text-align: center;
    color: #e74c3c;
    font-weight: 500;
    padding: 1rem;
}

/* Energy details container layout */
.energy-details-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Income/Savings section in energy details */
.income-savings-section {
    background-color: #e8f5e8;
    padding: 1rem;
    border-radius: 4px;
    border-left: 3px solid #27ae60;
}

.income-savings-section h3 {
    margin: 0 0 1rem 0;
    color: #27ae60;
    font-size: 1.1rem;
}

.income-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.income-detail-item {
    background-color: white;
    padding: 0.75rem;
    border-radius: 4px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.income-detail-item.total-benefit {
    background-color: #27ae60;
    color: white;
}

.income-detail-item h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #34495e;
    font-weight: 500;
}

.income-detail-item.total-benefit h4 {
    color: white;
}

.income-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #27ae60;
}

.income-value.total {
    color: white;
    font-size: 1.2rem;
}

.no-income-data {
    text-align: center;
    color: #7f8c8d;
    padding: 1rem;
}

.no-income-data p {
    margin: 0 0 1rem 0;
    font-style: italic;
}

/* Electricity prices section in energy details */
.electricity-prices-section {
    background-color: #fff3cd;
    padding: 1rem;
    border-radius: 4px;
    border-left: 3px solid #f39c12;
}

.electricity-prices-section h3 {
    margin: 0 0 1rem 0;
    color: #e67e22;
    font-size: 1.1rem;
}

.prices-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.price-detail-item {
    background-color: white;
    padding: 0.75rem;
    border-radius: 4px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.price-detail-item.feed-in {
    background-color: #e67e22;
    color: white;
}

.price-detail-item h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #34495e;
    font-weight: 500;
}

.price-detail-item.feed-in h4 {
    color: white;
}

.price-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e67e22;
    margin-bottom: 0.25rem;
}

.price-detail-item.feed-in .price-value {
    color: white;
}

.price-time {
    font-size: 0.8rem;
    color: #7f8c8d;
    font-style: italic;
}

.price-detail-item.feed-in .price-time {
    color: rgba(255,255,255,0.8);
}

/* Tariff breakdown section */
.tariff-breakdown-section h3 {
    margin: 0 0 1rem 0;
    color: #3498db;
    font-size: 1.1rem;
}

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

/* Right-align currency and numeric columns */
.data-table td.currency,
.data-table td.numeric {
    text-align: right;
}

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

/* Month Totals */
.month-totals {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.month-totals h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.total-item {
    text-align: center;
}

.total-item .label {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-bottom: 0.25rem;
}

.total-item .value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2c3e50;
}

/* Settings */
.settings-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.5rem;
}

.calculated-value {
    font-size: 1.2rem;
    color: #27ae60;
    font-weight: bold;
}

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

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-item label {
    font-weight: 600;
    color: #2c3e50;
}

.setting-input {
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 1rem;
}

.setting-input:focus {
    outline: none;
    border-color: #3498db;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
}

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

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    min-width: 500px;
}

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

.modal-header h3 {
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* 15-minute data table */
.time-data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.time-data-table th,
.time-data-table td {
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    text-align: center;
}

.time-data-table th {
    background-color: #ecf0f1;
    font-weight: 600;
}

.time-data-table input {
    width: 80px;
    padding: 0.25rem;
    border: 1px solid #bdc3c7;
    border-radius: 2px;
}

/* File Upload */
.file-upload {
    margin-bottom: 1rem;
}

.file-upload input[type="file"] {
    margin-bottom: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        min-width: 300px;
        margin: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

.hidden {
    display: none;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Success/Error Messages */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Status Messages for Tools */
.status-message {
    padding: 0.75rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    border: 1px solid;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.status-message.warning {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

.status-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
}

/* Tariff Breakdown Tooltips */
.tariff-breakdown {
    cursor: help;
    position: relative;
}

.tariff-breakdown:hover {
    background-color: #f8f9fa;
}

/* Refresh Button Animations */
.btn-small i.fa-sync-alt {
    transition: transform 0.3s ease;
}

.btn-small:hover i.fa-sync-alt {
    transform: rotate(180deg);
}

.btn-small:disabled i.fa-spinner {
    animation: spin 1s linear infinite;
}

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