/* ============================================================
   SEO Copywriting & Social Media Manager — główny arkusz CSS
   ============================================================ */

/* --- Reset i zmienne --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --secondary:     #64748b;
    --success:       #16a34a;
    --warning:       #d97706;
    --danger:        #dc2626;
    --info:          #0891b2;
    --bg:            #f8fafc;
    --surface:       #ffffff;
    --border:        #e2e8f0;
    --border-light:  #f1f5f9;
    --text:          #1e293b;
    --text-muted:    #64748b;
    --sidebar-width: 240px;
    --header-height: 56px;
    --radius:        6px;
    --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 14px;
       line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* --- Strona logowania / błędów --- */
.auth-body, .error-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--bg);
}

.auth-container {
    background: var(--surface); padding: 2rem; border-radius: var(--radius);
    box-shadow: var(--shadow-md); width: 100%; max-width: 400px;
}

.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo .logo-icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.auth-logo h1 { font-size: 1.25rem; font-weight: 600; color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.error-container { text-align: center; }
.error-container h1 { font-size: 6rem; color: var(--secondary); }
.error-container p  { margin: 1rem 0 1.5rem; color: var(--text-muted); }

/* --- Layout główny --- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width); background: #1e293b; color: #cbd5e1;
    display: flex; flex-direction: column; flex-shrink: 0;
    position: sticky; top: 0; align-self: flex-start; min-height: 100vh; height: auto; overflow-y: visible; z-index: 100;
}

.sidebar-logo {
    padding: 1rem 1.25rem; font-weight: 700; font-size: .875rem;
    color: #f1f5f9; border-bottom: 1px solid #334155; display: flex; align-items: center; gap: .5rem;
}

.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; }

.nav-section {
    padding: .65rem 1rem .4rem;
    font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: #7c8fa8;
    display: flex; align-items: center; justify-content: space-between;
    user-select: none;
    margin-top: .25rem;
    border-top: 1px solid #273447;
}
.nav-section:first-child { border-top: none; margin-top: 0; }
.nav-section:hover { color: #b0c4d8; }
.nav-section-arrow { color: #4e6175; font-size: .6rem; line-height: 1; transition: transform .2s; display: inline-block; }
.nav-section-arrow::before { content: '▾'; }
.nav-section.collapsed .nav-section-arrow { transform: rotate(-90deg); }
.nav-section-body.collapsed { display: none; }

.nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .45rem 1.1rem .45rem 1.25rem;
    color: #94a3b8; font-size: .855rem;
    transition: background .12s, color .12s;
    border-left: 2px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: rgba(99,102,241,.12); color: #fff; border-left-color: var(--primary); }
.nav-icon { width: 16px; text-align: center; flex-shrink: 0; opacity: .75; }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: .85rem 1.25rem; border-top: 1px solid #273447;
    font-size: .8rem; color: #64748b;
}

.main-content {
    flex: 1; display: flex; flex-direction: column; min-width: 0;
}

/* Breadcrumbs */
.breadcrumbs { display:flex; align-items:center; gap:.35rem; font-size:.8rem; color:var(--text-muted); padding:.4rem 0; border-bottom:1px solid var(--border); flex-wrap:wrap; margin-bottom:1.25rem; }
.breadcrumbs a { color:var(--text-muted); text-decoration:none; }
.breadcrumbs a:hover { color:var(--primary); text-decoration:underline; }
.breadcrumbs .bc-current { color:var(--text); font-weight:500; }
.breadcrumbs .bc-sep { color:#cbd5e1; font-size:.9rem; }

.topbar {
    height: var(--header-height); background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem; position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}

.topbar-title { font-weight: 600; font-size: 1rem; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.user-badge { font-size: .8rem; color: var(--text-muted); }

.page-content { padding: 1.5rem; flex: 1; }

/* --- Karty i sekcje --- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-weight: 600; font-size: .9rem; }
.card-body { padding: 1.25rem; }

/* --- Tabele --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
.table-wrap .data-table, .table-wrap table { min-width: 560px; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { background: var(--bg); font-weight: 600; text-align: left;
     padding: .625rem .875rem; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: .625rem .875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.text-muted { color: var(--text-muted); font-size: .8rem; }

/* --- Formularze --- */
.form-group { display: flex; flex-direction: column; gap: .375rem; }
.form-group label { font-weight: 500; font-size: .875rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=month], input[type=week], input[type=url], input[type=number], textarea, select {
    width: 100%; padding: .5rem .75rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: .875rem; font-family: inherit;
    background: var(--surface); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }

/* --- Przyciski --- */
.btn {
    display: inline-flex; align-items: center; gap: .375rem;
    padding: .5rem 1rem; border-radius: var(--radius);
    font-size: .875rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: all .15s; text-decoration: none !important;
    white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-delete-circle { background: none; border: none; cursor: pointer; padding: 0 2px; line-height: 1; vertical-align: middle; opacity: .8; }
.btn-delete-circle:hover { opacity: 1; }
.btn-archive { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.btn-archive:hover { background: #fde68a; border-color: #f59e0b; }
.btn-restore { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.btn-restore:hover { background: #a7f3d0; border-color: #34d399; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover    { background: #b91c1c; }
.btn-warning   { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover   { background: #b45309; }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm        { padding: .3rem .7rem; font-size: .8rem; }
.btn-full      { width: 100%; justify-content: center; }

/* --- Alerty --- */
.alert {
    padding: .75rem 1rem; border-radius: var(--radius);
    margin-bottom: 1rem; font-size: .875rem;
    display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
}
.alert-close {
    background: none; border: none; cursor: pointer; font-size: 1.1rem; line-height: 1;
    opacity: .5; padding: 0; flex-shrink: 0; color: inherit;
}
.alert-close:hover { opacity: 1; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #f0f9ff; color: #075985; border: 1px solid #bae6fd; }

/* --- Odznaki statusów --- */
.badge {
    display: inline-block; padding: .2rem .55rem; border-radius: 9999px;
    font-size: .75rem; font-weight: 500;
}
.badge-draft     { background: #f1f5f9; color: #475569; }
.badge-in_review { background: #fef9c3; color: #854d0e; }
.badge-approved  { background: #dcfce7; color: #166534; }
.badge-published { background: #dbeafe; color: #1d4ed8; }
.badge-rejected  { background: #fee2e2; color: #991b1b; }
.badge-scheduled { background: #ede9fe; color: #5b21b6; }
.badge-facebook  { background: #dbeafe; color: #1d4ed8; }
.badge-instagram { background: #fce7f3; color: #9d174d; }
.badge-both      { background: #f3e8ff; color: #6b21a8; }

/* --- Statystyki dashboard --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* --- Filtry i wyszukiwarka --- */
.filters-bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: .75rem;
    margin-bottom: 1rem;
}
.filters-bar select, .filters-bar input { width: auto; min-width: 140px; }
.filters-bar input[type=month], .filters-bar input[type=date], .filters-bar input[type=week] {
    min-width: 155px; max-width: 200px; cursor: pointer;
}

/* --- Paginacja --- */
.pagination-bar {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: .5rem 1rem; margin-top: 1rem; padding: .5rem 0;
}
.pagination-info { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }
.pagination-pages { display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2rem; height: 2rem; padding: 0 .4rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: .8rem; color: var(--text); text-decoration: none;
    transition: background .12s, color .12s;
}
.page-link:hover { background: var(--bg); text-decoration: none; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.page-link.disabled { color: var(--text-muted); pointer-events: none; opacity: .45; }
.page-link.page-nav { font-size: 1rem; }
.page-ellipsis { font-size: .8rem; color: var(--text-muted); padding: 0 .15rem; line-height: 2rem; }
.pagination-perpage { display: flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--text-muted); margin-left: auto; white-space: nowrap; }
.pagination-perpage label { margin-right: .1rem; }
.pp-link { padding: .2rem .45rem; border-radius: var(--radius); border: 1px solid var(--border); font-size: .75rem; color: var(--text); text-decoration: none; transition: background .12s; }
.pp-link:hover { background: var(--bg); text-decoration: none; }
.pp-link.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* --- Responsywność --- */
@media (max-width: 768px) {
    .sidebar { position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Sortowanie --- */
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--primary); }

/* --- Zakładki --- */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); }
.tab-link { padding: .5rem 1.25rem; text-decoration: none; color: var(--text-muted); border-radius: 4px 4px 0 0; font-size: .875rem; font-weight: 500; border: 2px solid transparent; border-bottom: none; margin-bottom: -2px; }
.tab-link:hover { color: var(--text); background: var(--bg-hover, #f5f5f5); }
.tab-link.active { color: var(--primary); border-color: var(--border); border-bottom-color: #fff; background: #fff; }
.badge-count { display: inline-flex; align-items: center; justify-content: center; background: var(--bg-muted, #e9ecef); color: var(--text-muted); border-radius: 999px; font-size: .75rem; font-weight: 600; padding: 0 .5rem; min-width: 1.5rem; height: 1.25rem; margin-left: .35rem; }
.tab-link.active .badge-count { background: var(--primary-light, #e8f0fe); color: var(--primary); }
.tab-btn { padding: .5rem 1.25rem; background: none; border: 2px solid transparent; border-bottom: none; border-radius: 4px 4px 0 0; margin-bottom: -2px; color: var(--text-muted); font-size: .875rem; font-weight: 500; cursor: pointer; font-family: inherit; }
.tab-btn:hover { color: var(--text); background: var(--bg-hover, #f5f5f5); }
.tab-btn.active { color: var(--primary); border-color: var(--border); border-bottom-color: #fff; background: #fff; }
.tip-icon { display:inline-flex;align-items:center;justify-content:center;width:15px;height:15px;border-radius:50%;background:var(--text-muted);color:#fff;font-size:.65rem;font-weight:700;cursor:help;vertical-align:middle;margin-left:.25rem;line-height:1;flex-shrink:0; }

/* --- Działania masowe --- */
.bulk-actions { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; background: #1e3a5f; border-radius: 0; flex-wrap: wrap; }
.bulk-actions .bulk-label { font-size: .875rem; color: #cbd5e1; font-weight: 500; }
.bulk-actions-sticky { position: fixed; bottom: 0; left: var(--sidebar-width, 240px); right: 0; z-index: 500; box-shadow: 0 -4px 20px rgba(0,0,0,.22); animation: bulkSlideUp .18s ease; }
@keyframes bulkSlideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* --- Generator hasła / pole hasła --- */
.pw-gen-wrap { display: flex; gap: .4rem; align-items: center; }
.pw-gen-wrap input { flex: 1; min-width: 0; }
.pw-generated-box { font-size: .85rem; padding: .5rem .75rem; }

/* --- Strona Moje konto --- */
.account-info-table { width: 100%; border-collapse: collapse; }
.account-info-table th, .account-info-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); font-size: .875rem; text-align: left; }
.account-info-table th { color: var(--text-muted); font-weight: 500; width: 45%; }
.account-info-table tr:last-child th, .account-info-table tr:last-child td { border-bottom: none; }

/* Zakładki na stronie konto (nie sidebar) */
.tab-bar { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); }

/* --- Odznaki ról --- */
.badge-role { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-admin         { background: #ede9fe; color: #6d28d9; }
.badge-manager       { background: #e0f2fe; color: #0369a1; }
.badge-doradca       { background: #fce7f3; color: #9d174d; }
.badge-editor        { background: #dcfce7; color: #15803d; }
.badge-client_viewer { background: #fef9c3; color: #854d0e; }
.badge-success { background: #dcfce7; color: #15803d; display:inline-block; padding:.15rem .55rem; border-radius:999px; font-size:.75rem; font-weight:600; }
.badge-danger  { background: #fee2e2; color: #b91c1c; display:inline-block; padding:.15rem .55rem; border-radius:999px; font-size:.75rem; font-weight:600; }

/* --- Przycisk XS --- */
.btn-xs { padding: .15rem .5rem; font-size: .75rem; }

/* --- Link filtrowania po kliencie w listach zadań --- */
.client-filter-link { color: var(--text-muted); text-decoration: none; }
.client-filter-link:hover { color: var(--primary); text-decoration: underline; }

/* Tooltip — obsługiwany przez JS w app.js (data-tip) */
.tip { cursor:help; }

/* Sort links */
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--primary); }
th:hover .sort-link { text-decoration: underline; }

/* =====================================================================
   Pakiety / Usługi klientów
   ===================================================================== */

/* --- Toggle switch --- */
.service-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}
.service-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.service-toggle-slider {
    display: inline-block;
    width: 42px;
    height: 22px;
    background: #cbd5e1;
    border-radius: 11px;
    transition: background .2s;
    position: relative;
}
.service-toggle-slider::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.service-toggle input:checked ~ .service-toggle-slider {
    background: var(--success, #22c55e);
}
.service-toggle input:checked ~ .service-toggle-slider::after {
    transform: translateX(20px);
}

/* --- Wiersz usługi w zakładce Pakiet --- */
.pkg-service-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--border);
    gap: .75rem;
}
.pkg-service-row:last-child { border-bottom: none; }
.pkg-service-info {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
}
.pkg-service-icon { font-size: 1.3rem; flex-shrink: 0; }
.pkg-service-name { font-weight: 600; font-size: .9rem; }
.pkg-service-badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .2rem; }
.pkg-status-label {
    font-size: .78rem;
    font-weight: 600;
    padding: .18rem .55rem;
    border-radius: 999px;
    white-space: nowrap;
}
.pkg-status-active   { background: #dcfce7; color: #15803d; }
.pkg-status-inactive { background: #f1f5f9; color: #64748b; }
.pkg-child-label {
    display: flex;
    align-items: center;
    gap: .3rem;
    cursor: pointer;
    padding: .2rem .4rem;
    border-radius: 4px;
}
.pkg-child-label:hover { background: #eff6ff; }

/* --- KPI Usługi (panel klienta) --- */
.services-kpi { margin-bottom: 1.75rem; }
.services-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}
.service-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: .85rem 1rem;
    border-radius: var(--radius, 8px);
    border: 1.5px solid var(--border);
    min-width: 100px;
    text-align: center;
    font-size: .85rem;
}
.service-card.active {
    background: #f0fdf4;
    border-color: #86efac;
}
.service-card.inactive {
    background: var(--surface, #f8fafc);
    border-color: #e2e8f0;
    opacity: .75;
}
.service-card-icon { font-size: 1.6rem; }
.service-card-name { font-weight: 600; color: var(--text); }
.service-card.inactive .service-card-name { color: var(--text-muted); }
.service-card-platforms { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: center; margin-top: .35rem; }
.sm-platform-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    flex-shrink: 0;
}
.btn-contact {
    display: inline-block;
    margin-top: .35rem;
    font-size: .75rem;
    padding: .25rem .6rem;
    background: var(--primary, #3b82f6);
    color: #fff;
    border-radius: 999px;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity .15s;
}
.btn-contact:hover { opacity: .85; }
