/* ====================================================================== */
/* GŁÓWNY, UNIWERSALNY ARKUSZ STYLÓW DLA BIZDO (ulepszony) */
/* ====================================================================== */

/* 1. ZMIENNE I PODSTAWOWE USTAWIENIA */
:root {
    --bg-light: #f4f7f9;
    --bg-white: #ffffff;
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    --primary: #3498db;
    --primary-hover: #2980b9;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --border-color: #e1e8ed;
    --success: #27ae60;
    --transition: all 0.25s ease-in-out;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* 2. KOMPONENTY WSPÓLNE */

/* Przyciski */
.primary-btn, .secondary-btn, .danger-btn {
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: var(--transition);
}
.primary-btn { background-color: var(--primary); color: white; }
.primary-btn:hover { background-color: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.secondary-btn { background-color: #ecf0f1; color: var(--text-dark); border: 1px solid var(--border-color); }
.secondary-btn:hover { background-color: #dfe6e9; }
.danger-btn { background-color: var(--danger); color: white; }
.danger-btn:hover { background-color: var(--danger-hover); transform: translateY(-1px); }

/* Formularze */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 12px; background: var(--bg-white);
    border: 1px solid var(--border-color); color: var(--text-dark);
    border-radius: 8px; box-sizing: border-box; font-size: 15px;
    transition: var(--transition);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
    outline: none;
}
.form-actions { margin-top: 30px; text-align: right; }
.form-actions button { margin-left: 10px; }

/* Karty */
.card {
    background-color: var(--bg-white);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.card h3 { margin-top: 0; }

/* 3. BIZPANEL */

.bizpanel-body { display: flex; }
.sidebar {
    width: 250px; background-color: var(--bg-white);
    min-height: 100vh; padding: 20px;
    border-right: 1px solid var(--border-color);
    transition: var(--transition);
}
.sidebar-header { text-align: center; margin-bottom: 30px; }
.sidebar-header h2 { color: var(--primary); margin: 0; }
.plan-badge { display: inline-block; background-color: var(--primary); color: white; padding: 3px 10px; font-size: 0.75em; font-weight: bold; border-radius: 15px; margin-top: 5px; text-transform: uppercase; }
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav a {
    display: block; color: var(--text-dark); text-decoration: none;
    padding: 12px 18px; border-radius: 8px; margin-bottom: 5px;
    transition: var(--transition);
}
.sidebar-nav a:hover, .sidebar-nav a.active { background-color: var(--primary); color: white; }
.user-info { text-align: center; margin-top: 40px; color: var(--text-muted); font-size: 0.9em; }
.logout-link { color: var(--primary); font-weight: bold; }
.main-content { flex-grow: 1; padding: 40px; }
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border-color); padding-bottom: 20px; margin-bottom: 30px;
}
.page-header h1 { margin: 0; }

/* Tabele */
.data-table {
    width: 100%; border-collapse: collapse;
    background-color: var(--bg-white); border-radius: 8px; overflow: hidden;
}
.data-table th, .data-table td {
    padding: 15px; text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.data-table th { background-color: #f8f9fa; font-weight: 600; }
.data-table tr:hover { background-color: #f9fcff; }
.data-table tr:last-child td { border-bottom: none; }
.data-table td .secondary-btn, .data-table td .danger-btn { padding: 5px 10px; margin-right: 5px; }

/* Modale */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(44, 62, 80, 0.7);
    display: none; justify-content: center; align-items: center;
    z-index: 9999;
}
.modal-content {
    background: var(--bg-white); padding: 30px; border-radius: 12px;
    width: 100%; max-width: 500px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    animation: fadeIn 0.3s ease-in-out;
}
.modal-content h2 { margin-top: 0; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95);} to {opacity: 1; transform: scale(1);} }

/* Baner Impersonacji */
.impersonation-bar {
    background-color: #f39c12; color: white;
    padding: 10px; font-weight: bold; width: 100%;
    position: sticky; top: 0; z-index: 2000;
    display: flex; justify-content: center; align-items: center;
    box-sizing: border-box;
}
.impersonation-bar a { color: white; text-decoration: underline; margin-left: 8px; }

/* KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
}
.kpi-card {
    display: flex; align-items: center; gap: 20px;
    background-color: var(--bg-white);
    padding: 25px; border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.kpi-card:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.kpi-card .card-icon {
    font-size: 2.5em; background-color: var(--bg-light);
    width: 60px; height: 60px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
}
.kpi-card .card-content { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.kpi-card .card-title { color: var(--text-muted); font-size: 0.9em; margin-bottom: 5px; }
.kpi-card .card-value { font-size: 2em; font-weight: 700; line-height: 1.2; }
.kpi-card .card-currency { display: none; }
.kpi-card.balance .card-icon { background-color: #d4edda; }
.kpi-card.customers .card-icon { background-color: #cce5ff; }
.kpi-card.balance.positive .card-value { color: var(--success); }
.kpi-card.balance.negative .card-value { color: var(--danger); }

/* Paski postępu */
.limit-bar-container { margin-bottom: 20px; }
.limit-bar-container:last-child { margin-bottom: 0; }
.progress-bar { width: 100%; background-color: #ecf0f1; border-radius: 5px; height: 10px; overflow: hidden; margin: 5px 0; }
.progress { height: 100%; width: 0%; background-color: var(--primary); border-radius: 5px; transition: width 0.5s ease-in-out; }
.progress-label { color: var(--text-muted); font-size: 0.9em; }
#recent-sales-list { list-style: none; padding: 0; margin: 0; }
#recent-sales-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
#recent-sales-list li:last-child { border-bottom: none; }
.event-details { color: var(--text-muted); }
.event-value { font-weight: bold; }

/* Flash messages */
.flash-message {
    padding: 15px; margin-bottom: 20px;
    border-radius: 8px; font-weight: 500;
    transition: var(--transition);
}
.flash-message:hover { transform: translateY(-1px); }
.flash-success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }


/* ====================================================================== */
/* 4. RESPONSYWNOŚĆ DLA BIZPANELU */
/* ====================================================================== */

/* ====================================================================== */
/* 4. RESPONSYWNOŚĆ "MOBILE-FIRST" DLA BIZPANELU */
/* ====================================================================== */

/* Domyślne style dla urządzeń mobilnych (poniżej 992px) */
.bizpanel-body {
    display: block; /* WAŻNE: Na mobilkach body nie jest flexem */
}

.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-sizing: border-box;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-container h2 {
    margin: 0;
    color: var(--primary);
}

.menu-toggle-btn {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -280px; /* Domyślnie ukryty poza ekranem */
    width: 280px;
    height: 100dvh; /* Używamy dvh dla lepszego dopasowania na mobilkach */
    background-color: var(--bg-white);
    padding: 20px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    z-index: 1010;
    transition: left 0.3s ease-in-out;
    overflow-y: auto;
    box-sizing: border-box;
}

.sidebar.is-open {
    left: 0; /* Pokazuje menu */
}

/* Przyciemnienie tła, gdy menu jest otwarte */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1005;
    display: none; /* Domyślnie ukryte */
}
.overlay.is-visible {
    display: block;
}

.main-content {
    padding: 20px;
}

/* Style dla większych ekranów (powyżej 992px) - przywracamy stary wygląd */
@media (min-width: 992px) {
    .mobile-header {
        display: none; /* Ukryj mobilny nagłówek */
    }

    .bizpanel-body {
        display: flex; /* Włączamy flexbox dla układu kolumnowego */
    }

    .sidebar {
        position: static; /* Przywracamy normalną pozycję */
        left: 0;
        width: 250px;
        height: 100vh;
        border-right: 1px solid var(--border-color);
        box-shadow: none;
    }
    
    .main-content {
        flex-grow: 1;
        padding: 40px;
    }
}

/* Wrapper dla responsywnych tabel */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto; /* To jest kluczowa właściwość! */
    -webkit-overflow-scrolling: touch; /* Zapewnia płynne przewijanie na iOS */
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

/* Lekka poprawka dla samej tabeli wewnątrz wrappera */
.table-responsive-wrapper .data-table {
    border: none; /* Usuwamy ramkę z tabeli, bo ma ją wrapper */
    border-radius: 0;
    margin-bottom: 0; /* Usuwamy ewentualny margines */
}


.toggle-switch-group { display: flex; align-items: center; gap: 15px; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--primary); }
input:focus + .slider { box-shadow: 0 0 1px var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }