/* =====================================================
   BHP System - Główny arkusz stylów
   ===================================================== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary:       #1a2e4a;
    --primary-light: #243d61;
    --primary-dark:  #111e30;
    --accent:        #2980b9;
    --accent-light:  #3498db;
    --green:         #27ae60;
    --green-light:   #2ecc71;
    --orange:        #e67e22;
    --orange-light:  #f39c12;
    --red:           #c0392b;
    --red-light:     #e74c3c;
    --bg:            #f4f6f9;
    --card-bg:       #ffffff;
    --text:          #2c3e50;
    --text-muted:    #7f8c8d;
    --border:        #dce3ec;
    --sidebar-w:     260px;
    --header-h:      64px;
    --radius:        10px;
    --shadow:        0 2px 12px rgba(26,46,74,0.10);
    --shadow-hover:  0 6px 24px rgba(26,46,74,0.16);
    --transition:    0.2s ease;
}

html { font-size: 15px; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* =====================================================
   SIDEBAR
   ===================================================== */

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    min-height: 100vh;
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
}

.sidebar-logo {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-icon {
    width: 40px; height: 40px;
    background: var(--accent);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.6rem;
}

.sidebar-logo .logo-icon::before {
    content: '';
    display: block;
    width: 18px; height: 22px;
    border: 2.5px solid #fff;
    border-radius: 2px;
    position: relative;
}

.sidebar-logo .logo-icon::after {
    content: '';
    position: absolute;
    width: 10px; height: 2px;
    background: #fff;
    border-radius: 1px;
    box-shadow: 0 4px 0 #fff, 0 8px 0 #fff;
    margin-left: -5px;
}

.sidebar-logo h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.sidebar-logo p {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    padding: 0.75rem 1.25rem 0.35rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.72rem 1.25rem;
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
    border-left-color: var(--accent-light);
}

.sidebar-nav a.active {
    background: rgba(41,128,185,0.18);
    color: #fff;
    border-left-color: var(--accent-light);
}

.nav-icon {
    width: 20px; height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* CSS-only icons */
.icon-dashboard::before {
    content: '';
    display: block;
    width: 16px; height: 16px;
    border: 2px solid currentColor;
    border-radius: 3px;
    position: relative;
    box-shadow: inset -7px -7px 0 0 currentColor;
}

.icon-docs {
    position: relative;
}
.icon-docs::before {
    content: '';
    display: block;
    width: 13px; height: 16px;
    border: 2px solid currentColor;
    border-radius: 2px;
}
.icon-docs::after {
    content: '';
    position: absolute;
    left: 3px; top: 5px;
    width: 7px; height: 1.5px;
    background: currentColor;
    box-shadow: 0 3px 0 currentColor, 0 6px 0 currentColor;
}

.icon-upload::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 9px solid currentColor;
    margin-bottom: 1px;
}
.icon-upload::after {
    content: '';
    display: block;
    width: 10px; height: 2px;
    background: currentColor;
    margin: 0 auto;
    box-shadow: 0 3px 0 currentColor;
}

.icon-people::before {
    content: '';
    display: block;
    width: 8px; height: 8px;
    border: 2px solid currentColor;
    border-radius: 50%;
    margin-bottom: 2px;
}
.icon-people::after {
    content: '';
    display: block;
    width: 14px; height: 6px;
    border: 2px solid currentColor;
    border-radius: 7px 7px 0 0;
    margin: 0 auto;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.72rem;
    color: rgba(255,255,255,0.3);
}

/* =====================================================
   MAIN LAYOUT
   ===================================================== */

.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--header-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.topbar h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.main-content {
    padding: 2rem;
    flex: 1;
}

/* =====================================================
   ALERTS / FLASH MESSAGES
   ===================================================== */

.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.88rem;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.alert-success {
    background: #eafaf1;
    border-color: var(--green);
    color: #1e8449;
}

.alert-error {
    background: #fdf0ef;
    border-color: var(--red);
    color: var(--red);
}

.alert-info {
    background: #eaf4fb;
    border-color: var(--accent);
    color: #1a5276;
}

/* =====================================================
   DASHBOARD STAT CARDS
   ===================================================== */

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

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.1rem;
    transition: box-shadow var(--transition), transform var(--transition);
    border-top: 4px solid transparent;
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.stat-card.card-total   { border-top-color: var(--accent); }
.stat-card.card-signed  { border-top-color: var(--green); }
.stat-card.card-pending { border-top-color: var(--orange); }
.stat-card.card-people  { border-top-color: var(--primary); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.si-blue   { background: #e8f4fd; color: var(--accent); }
.stat-icon.si-green  { background: #eafaf1; color: var(--green); }
.stat-icon.si-orange { background: #fef9e7; color: var(--orange); }
.stat-icon.si-navy   { background: #eaf0f6; color: var(--primary); }

/* CSS stat icons */
.si-doc-icon {
    width: 22px; height: 26px;
    border: 2.5px solid currentColor;
    border-radius: 3px;
    position: relative;
}
.si-doc-icon::after {
    content: '';
    position: absolute;
    left: 3px; top: 5px;
    width: 10px; height: 2px;
    background: currentColor;
    box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor;
}

.si-check-icon {
    width: 22px; height: 22px;
    border: 2.5px solid currentColor;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.si-check-icon::after {
    content: '';
    width: 10px; height: 5px;
    border-left: 2.5px solid currentColor;
    border-bottom: 2.5px solid currentColor;
    transform: rotate(-45deg) translateY(-2px);
}

.si-clock-icon {
    width: 22px; height: 22px;
    border: 2.5px solid currentColor;
    border-radius: 50%;
    position: relative;
}
.si-clock-icon::before {
    content: '';
    position: absolute;
    left: 9px; top: 4px;
    width: 2px; height: 7px;
    background: currentColor;
    transform-origin: bottom center;
}
.si-clock-icon::after {
    content: '';
    position: absolute;
    left: 9px; top: 9px;
    width: 6px; height: 2px;
    background: currentColor;
    transform-origin: left center;
}

.si-people-icon {
    position: relative;
    width: 24px; height: 24px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.si-people-icon::before {
    content: '';
    width: 9px; height: 9px;
    border: 2.5px solid currentColor;
    border-radius: 50%;
    position: absolute;
    top: 0; left: 2px;
}
.si-people-icon::after {
    content: '';
    width: 14px; height: 7px;
    border: 2.5px solid currentColor;
    border-radius: 7px 7px 0 0;
    position: absolute;
    bottom: 0; left: 0;
}

.stat-info .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-info .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* =====================================================
   CARDS / PANELS
   ===================================================== */

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}

.card-body {
    padding: 1.5rem;
}

/* =====================================================
   TABLES
   ===================================================== */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: #f8fafc; }

tbody td {
    padding: 0.8rem 1rem;
    vertical-align: middle;
}

.td-name strong {
    display: block;
    color: var(--primary);
    font-weight: 600;
}

.td-name span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* =====================================================
   BADGES
   ===================================================== */

.badge {
    display: inline-block;
    padding: 0.28rem 0.7rem;
    border-radius: 20px;
    font-size: 0.73rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-signed   { background: #eafaf1; color: #1e8449; }
.badge-pending  { background: #fef9e7; color: #9a6400; }
.badge-rejected { background: #fdf0ef; color: var(--red); }

/* =====================================================
   BUTTONS
   ===================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: 7px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-light); box-shadow: 0 4px 12px rgba(41,128,185,0.3); }

.btn-success {
    background: var(--green);
    color: #fff;
}
.btn-success:hover { background: var(--green-light); box-shadow: 0 4px 12px rgba(39,174,96,0.3); }

.btn-danger {
    background: var(--red);
    color: #fff;
}
.btn-danger:hover { background: var(--red-light); }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; }

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* =====================================================
   FORMS
   ===================================================== */

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--primary);
}

input[type="text"],
input[type="email"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 0.88rem;
    color: var(--text);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="file"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.12);
}

textarea { min-height: 100px; resize: vertical; }

input[type="file"] {
    padding: 0.5rem;
    background: #fafbfc;
    cursor: pointer;
}

.form-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* =====================================================
   DOCUMENT DETAIL
   ===================================================== */

.doc-detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.detail-row {
    display: flex;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 160px;
    flex-shrink: 0;
}

.detail-value {
    font-size: 0.88rem;
    color: var(--text);
}

.doc-actions-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* =====================================================
   EMPLOYEE CARDS
   ===================================================== */

.employees-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.employee-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow var(--transition), transform var(--transition);
}

.employee-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.employee-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.employee-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.employee-info p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* =====================================================
   PAGE HEADER
   ===================================================== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
}

.page-header p {
    font-size: 0.83rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* =====================================================
   UPLOAD AREA
   ===================================================== */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    transition: border-color var(--transition), background var(--transition);
    cursor: pointer;
    background: #fafbfc;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: #eaf4fb;
}

.upload-zone p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.5rem;
}

.upload-icon {
    width: 48px; height: 48px;
    margin: 0 auto 0.75rem;
    position: relative;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-icon::before {
    content: '';
    display: block;
    width: 0; height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 18px solid var(--accent);
    margin-bottom: 2px;
}

.upload-icon::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px; height: 3px;
    background: var(--accent);
    border-radius: 2px;
    box-shadow: 0 6px 0 var(--accent);
}

/* =====================================================
   EMPTY STATE
   ===================================================== */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p { margin-top: 0.5rem; font-size: 0.88rem; }

/* =====================================================
   SEARCH / FILTER BAR
   ===================================================== */

.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar input,
.filter-bar select {
    width: auto;
    flex: 1;
    min-width: 160px;
    max-width: 260px;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 900px) {
    :root { --sidebar-w: 220px; }
}

@media (max-width: 700px) {
    .sidebar {
        width: 100%;
        min-height: auto;
        position: relative;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .doc-detail-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .main-content { padding: 1rem; }
}

/* =====================================================
   MISC
   ===================================================== */

.text-muted { color: var(--text-muted); }
.text-green  { color: var(--green); }
.text-orange { color: var(--orange); }
.text-red    { color: var(--red); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

hr.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.file-type-icon {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--bg);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

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

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    margin-top: 1.25rem;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 6px;
    font-size: 0.83rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.pagination a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
