/* Reset i podstawowe style */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header .subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Main content */
main {
    padding: 40px 0;
}

/* Wykresy */
.charts-container {
    margin-top: 20px;
}

.chart-wrapper {
    background: white;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-title {
    font-size: 1.8em;
    color: #2c3e50;
    margin-bottom: 10px;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.chart-description {
    color: #666;
    margin-bottom: 20px;
    font-size: 1.05em;
}

.chart-source {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.9em;
    color: #777;
    font-style: italic;
}

.chart-source a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s;
}

.chart-source a:hover {
    color: #5568d3;
    text-decoration: underline;
}

.chart-sources {
    margin-top: 15px;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-left: 3px solid #667eea;
    border-radius: 4px;
    font-size: 0.9em;
    color: #555;
}

.chart-sources strong {
    color: #333;
}

.chart-sources a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s;
}

.chart-sources a:hover {
    color: #5568d3;
    text-decoration: underline;
}

.chart-sources small {
    color: #999;
    font-size: 0.85em;
}

.chart-plot {
    width: 100%;
    height: 450px;
    margin-top: 20px;
    margin-bottom: 40px;
    padding-bottom: 30px;
}

/* Rotacja etykiet na osi X dla lepszej czytelności */
.chart-plot .flot-x-axis .flot-tick-label {
    transform: rotate(-90deg);
    transform-origin: center center;
    white-space: nowrap;
    margin-top: 18px !important;
}

.chart-no-data {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

/* Legenda */
.legend-box {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-top: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.legend-box h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-color {
    width: 30px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.legend-line {
    width: 30px;
    height: 3px;
    display: block;
}

/* Loading i błędy */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 1.1em;
}

.error {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 5px;
    padding: 20px;
    margin: 20px 0;
    color: #c00;
}

.no-charts {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.no-charts p {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 10px;
}

/* ============================================
   PANEL ADMINISTRACYJNY
   ============================================ */

.admin-page {
    background-color: #f0f2f5;
}

/* Header administracyjny */
.admin-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.admin-header h1 {
    font-size: 1.8em;
    margin-bottom: 0;
}

.admin-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-nav {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Strona logowania */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    border-radius: 10px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 10px;
}

.login-box .subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 0.95em;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.login-footer a {
    color: #667eea;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* Alerty */
.alert {
    padding: 12px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-error {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c00;
}

.alert-success {
    background-color: #efe;
    border: 1px solid #cfc;
    color: #060;
}

/* Formularze */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

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

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

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Przyciski */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover {
    background-color: #5568d3;
}

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

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

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

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

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

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

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

.btn-block {
    display: block;
    width: 100%;
}

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

/* Container administracyjny */
.admin-container {
    padding: 30px 0;
}

.admin-section {
    background: white;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

.section-header h2 {
    color: #2c3e50;
    font-size: 1.8em;
}

/* Lista wykresów w panelu admin */
.charts-list {
    display: grid;
    gap: 20px;
}

.chart-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    transition: box-shadow 0.3s;
}

.chart-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-card-header h3 {
    color: #2c3e50;
    font-size: 1.4em;
    margin: 0;
}

.chart-order {
    background-color: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
}

.chart-card-body {
    margin-bottom: 15px;
    color: #555;
}

.chart-meta {
    font-size: 0.9em;
    color: #777;
    margin-top: 5px;
}

.chart-card-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

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

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideDown 0.3s;
}

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

.modal-large {
    max-width: 900px;
}

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

.modal-header h3 {
    color: #2c3e50;
    font-size: 1.5em;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
}

/* Tabela danych */
.data-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.data-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 20px;
}

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

.data-table thead {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #e0e0e0;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

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

.data-table .no-data {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 30px;
}

/* Formularz danych i import */
#data-form-container,
#bulk-import-container {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 20px;
    margin-top: 20px;
}

#data-form-container h4,
#bulk-import-container h4 {
    color: #2c3e50;
    margin-bottom: 15px;
}

#bulk-data {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    margin-top: 10px;
}

/* Responsywność */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
        width: 100%;
    }
    
    body {
        overflow-x: hidden;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    header .subtitle {
        font-size: 1em;
    }
    
    .chart-wrapper {
        padding: 15px;
        margin-bottom: 30px;
        overflow-x: hidden;
    }
    
    .chart-title {
        font-size: 1.3em;
        word-wrap: break-word;
    }
    
    .chart-description {
        font-size: 0.95em;
    }
    
    .chart-plot {
        height: 350px;
        width: 100%;
        margin-bottom: 40px;
        padding-bottom: 35px;
    }
    
    /* Rotacja etykiet na mobile z większym marginesem */
    .chart-plot .flot-x-axis .flot-tick-label {
        margin-top: 22px !important;
    }
    
    /* Lepsze wyświetlanie legendy na mobile */
    .legend-items {
        flex-direction: column;
        gap: 10px;
    }
    
    .legend-item {
        font-size: 0.9em;
    }
    
    .chart-sources {
        font-size: 0.8em;
        padding: 10px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .admin-header .container {
        flex-direction: column;
        gap: 15px;
    }
    
    .admin-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .chart-card-actions {
        flex-direction: column;
    }
    
    .chart-card-actions .btn {
        width: 100%;
    }
}

/* Tooltip dla wykresów */
#chart-tooltip {
    white-space: nowrap;
}

/* Brak danych */
.no-data {
    text-align: center;
    padding: 20px;
    color: #999;
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 250px;
    max-width: 400px;
    font-size: 14px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    cursor: pointer;
}

.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid #27ae60;
    background: #d4edda;
    color: #155724;
}

.toast-error {
    border-left: 4px solid #e74c3c;
    background: #fee;
    color: #c00;
}

.toast-icon {
    font-weight: bold;
    font-size: 16px;
    margin-right: 8px;
}

.toast:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

