/* ============================================
   STATYSTYKI - STYLOWANIE (ZOPTYMALIZOWANE)
   ============================================ */

/* Reset i Scroll */
html, body {
    height: auto !important;  
    min-height: 100vh;            
    overflow-y: auto !important;   
    overflow-x: hidden;            
}

.app-container {
    height: auto !important;  
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: visible !important;  
}

.app-main-stats {
    flex: 1;                       
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 20px 50px 20px;
    box-sizing: border-box;
    overflow: visible !important; 
    height: auto !important;
}


/* KPI SECTION */
.stats-kpi-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-bottom: 30px;
}

.kpi-card-stats {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 110px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    cursor: pointer;
}

.kpi-card-stats:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.kpi-icon-stats {
    font-size: 40px;
    min-width: 50px;
    text-align: center;
}

.kpi-content-stats h3 {
    margin: 0 0 6px 0;
    font-size: 11px;
    color: var(--text-secondary-color);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value-stats {
    font-size: 26px;
    font-weight: 800;
    color: var(--stat-value);
    line-height: 1.2;
}

.kpi-label-stats {
    margin: 0;
    font-size: 11px;
    color: var(--text-secondary-color);
    opacity: 0.8;
}

/* GRID LAYOUT */
.stats-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

/* CARD STYLES */
.stat-card {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

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

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.stat-card h2 {
    margin: 0;
    font-size: 18px;
    color: var(--card-title);
    font-weight: 700;
}

.stat-badge {
    background: var(--search-item-hover-bg);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

/* FILTER BAR */
.filter-bar {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary-color);
    white-space: nowrap;
}

.filter-group select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-color);
    color: var(--text-color);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-group select:hover,
.filter-group select:focus {
    border-color: var(--primary);
    outline: none;
}

/* EXPORT BUTTON */
.export-btn-inline {
    padding: 8px 14px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: background-color 0.3s ease;
    margin-left: auto; 
}

.export-btn-inline:hover {
    background: var(--primary-light);
}

.export-info {
    font-size: 11px;
    color: var(--text-secondary-color);
    margin: 8px 0 12px 0;
    padding: 8px 12px;
    background: var(--bg-color);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
}

/* (Parametry + Uprawy) */
.stat-card-split {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.split-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.split-left, .split-right {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.split-left h2, .split-right h2 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: var(--card-title);
    font-weight: 700;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

/* PARAMETRY GRID */
.stats-params-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-param-item {
    background: var(--bg-color);
    padding: 14px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.stat-param-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.stat-param-label {
    margin: 0 0 4px 0;
    font-size: 10px;
    color: var(--text-secondary-color);
    font-weight: 700;
    text-transform: uppercase;
}

.stat-param-value {
    margin: 0 0 4px 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--stat-value);
}

.stat-param-info {
    margin: 0;
    font-size: 10px;
    color: var(--text-secondary-color);
    opacity: 0.8;
}

/* UPRAWY LIST */
.uprawy-list-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.uprawa-item-stats {
    background: var(--bg-color);
    padding: 12px 14px;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
    transition: all 0.2s ease;
}

.uprawa-item-stats:hover {
    border-left-color: var(--accent);
    background: var(--surface-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.uprawa-item-stats strong {
    display: block;
    margin-bottom: 4px;
    color: var(--primary);
    font-size: 13px;
}

.uprawa-stats-data {
    font-size: 11px;
    color: var(--text-secondary-color);
    display: flex;
    justify-content: space-between;
}

/* TABLES */
.stat-table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.stat-table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    font-size: 13px;
}

.stat-table thead {
    background: var(--table-header-bg);
    color: var(--table-header-text);
}

.stat-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.stat-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-table tbody tr:hover {
    background: var(--table-row-hover-bg);
}

.stat-table tbody tr:last-child td {
    border-bottom: none;
}

.stat-loading {
    text-align: center;
    color: var(--text-secondary-color);
    padding: 20px !important;
    font-style: italic;
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .split-container { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: flex-start; gap: 12px; }
    .export-btn-inline { margin-left: 0; width: 100%; }
}

@media (max-width: 768px) {
    .stats-kpi-section { grid-template-columns: 1fr 1fr; }
    .stats-params-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-kpi-section { grid-template-columns: 1fr; }
    .kpi-icon-stats { font-size: 32px; }
    .kpi-value-stats { font-size: 22px; }
}