/* ============================================
   SLPS - System Losowego Przydziału Spraw
   Styl sądowy, poważny, profesjonalny
   ============================================ */

:root {
    --bg-primary: #0c1222;
    --bg-secondary: #111a2e;
    --bg-card: #162035;
    --bg-hover: #1c2a47;
    --bg-input: #0f1829;
    --border: #1e2d4a;
    --border-light: #263554;
    --text-primary: #e2e8f0;
    --text-secondary: #8b9dc3;
    --text-muted: #5a6f94;
    --accent: #c9a84c;
    --accent-hover: #dbb95d;
    --accent-dim: rgba(201, 168, 76, 0.1);
    --danger: #dc4a5a;
    --success: #3dae72;
    --info: #4a8fd4;
    --warning: #d4a44a;
    --sidebar-width: 260px;
    --header-height: 60px;
    --font-display: 'Source Serif 4', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.4);
    --radius: 6px;
    --radius-lg: 10px;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--accent), #a88832);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #0c1222; font-size: 18px;
}
.sidebar-title-main {
    font-family: var(--font-display);
    font-size: 1.3em;
    font-weight: 700;
    color: var(--accent);
    display: block;
    letter-spacing: 1px;
}
.sidebar-title-sub {
    font-size: 0.7em;
    color: var(--text-muted);
}
.sidebar-court {
    padding: 10px 20px;
    font-size: 0.75em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.88em;
    transition: all 0.2s;
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-item i { width: 20px; text-align: center; font-size: 0.95em; }

.nav-divider { height: 1px; background: var(--border); margin: 10px 14px; }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
}
.sidebar-user i { font-size: 1.5em; color: var(--text-muted); }
.sidebar-user-name { font-size: 0.85em; font-weight: 500; }
.sidebar-user-role { font-size: 0.7em; color: var(--text-muted); }
.nav-logout { color: var(--danger) !important; }
.nav-logout:hover { background: rgba(220,74,90,0.1) !important; }

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}
.main-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0; z-index: 50;
}
.sidebar-toggle {
    background: none; border: none; color: var(--text-secondary);
    cursor: pointer; font-size: 1.1em; padding: 6px;
    display: none;
}
.page-title {
    font-family: var(--font-display);
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-primary);
}
.header-right { margin-left: auto; color: var(--text-muted); font-size: 0.85em; }

.content-wrapper { padding: 24px; }

/* ============ FLASH MESSAGES ============ */
.flash-messages { padding: 16px 24px 0; }
.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    font-size: 0.88em;
    transition: opacity 0.3s;
    position: relative;
}
.alert i { font-size: 1.1em; }
.alert-close {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: inherit; cursor: pointer; font-size: 1.2em; opacity: 0.6;
}
.alert-success { background: rgba(61,174,114,0.12); color: var(--success); border: 1px solid rgba(61,174,114,0.25); }
.alert-error { background: rgba(220,74,90,0.12); color: var(--danger); border: 1px solid rgba(220,74,90,0.25); }
.alert-info { background: rgba(74,143,212,0.12); color: var(--info); border: 1px solid rgba(74,143,212,0.25); }

/* ============ CARDS & WIDGETS ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-title {
    font-family: var(--font-display);
    font-size: 1.05em;
    font-weight: 600;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 2em;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 6px;
}
.stat-label { font-size: 0.8em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ============ TABLES ============ */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88em;
}
table th, table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 0.5px;
}
table tr:hover td { background: var(--bg-hover); }
table .text-right { text-align: right; }
table .text-center { text-align: center; }

.row-pool { background: rgba(201,168,76,0.08) !important; }
.row-drawn { background: rgba(61,174,114,0.12) !important; font-weight: 600; }
.row-excluded { color: var(--text-muted); font-style: italic; }

/* ============ FORMS ============ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82em;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.92em;
    transition: border-color 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 80px; resize: vertical; }

.form-check {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px; cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-inline {
    display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
}
.form-inline .form-group { margin-bottom: 0; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.88em;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn i { font-size: 0.9em; }
.btn-primary { background: var(--accent); color: #0c1222; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.btn-secondary:hover { background: var(--border-light); }
.btn-danger { background: rgba(220,74,90,0.15); color: var(--danger); border-color: rgba(220,74,90,0.3); }
.btn-danger:hover { background: rgba(220,74,90,0.25); }
.btn-success { background: rgba(61,174,114,0.15); color: var(--success); border-color: rgba(61,174,114,0.3); }
.btn-success:hover { background: rgba(61,174,114,0.25); }
.btn-sm { padding: 5px 12px; font-size: 0.82em; }
.btn-lg { padding: 12px 28px; font-size: 1em; }
.btn-block { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ BADGES ============ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: 600;
}
.badge-active { background: rgba(61,174,114,0.15); color: var(--success); }
.badge-completed { background: rgba(74,143,212,0.15); color: var(--info); }
.badge-manual { background: rgba(212,164,74,0.15); color: var(--warning); }
.badge-admin { background: rgba(220,74,90,0.15); color: var(--danger); }
.badge-przewodniczacy { background: rgba(201,168,76,0.15); color: var(--accent); }
.badge-sekretarz { background: rgba(74,143,212,0.15); color: var(--info); }

/* ============ DRAW RESULT ============ */
.draw-result {
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 20px 0;
}
.draw-result-header {
    text-align: center;
    margin-bottom: 20px;
}
.draw-result-title {
    font-family: var(--font-display);
    font-size: 1.1em;
    color: var(--accent);
    margin-bottom: 4px;
}
.draw-result-referee {
    font-family: var(--font-display);
    font-size: 1.4em;
    font-weight: 700;
    color: var(--text-primary);
}
.draw-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin: 16px 0;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}
.draw-meta-item { }
.draw-meta-label { font-size: 0.75em; color: var(--text-muted); text-transform: uppercase; }
.draw-meta-value { font-weight: 500; }

/* ============ REPORT VIEW (PDF-like) ============ */
.report-preview {
    background: white;
    color: #000;
    padding: 40px 50px;
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Times New Roman', Times, serif;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: var(--shadow-lg);
}
.report-preview h1 { font-size: 16px; margin: 12px 0; }
.report-preview table { border-collapse: collapse; width: 100%; font-size: 11px; }
.report-preview table th, .report-preview table td {
    border: 1px solid #000;
    padding: 4px 8px;
    text-align: left;
    background: transparent;
    color: #000;
}
.report-preview table th { background: #f0f0f0; font-weight: bold; }
.report-preview .pool-row { background: #e8e8e8 !important; }

/* ============ LOGIN PAGE ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0c1222 0%, #1a2744 100%);
}
.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 400px;
    max-width: 90%;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    text-align: center;
    margin-bottom: 30px;
}
.login-logo i { font-size: 3em; color: var(--accent); margin-bottom: 12px; display: block; }
.login-logo h1 {
    font-family: var(--font-display);
    font-size: 1.4em;
    color: var(--accent);
    letter-spacing: 2px;
}
.login-logo p { color: var(--text-muted); font-size: 0.85em; margin-top: 4px; }
.login-court {
    text-align: center;
    font-size: 0.82em;
    color: var(--text-secondary);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3em; margin-bottom: 12px; opacity: 0.3; display: block; }
.empty-state p { margin-bottom: 16px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.collapsed { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============ MISC ============ */
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }

/* Print styles */
@media print {
    .sidebar, .main-header, .flash-messages, .btn, .sidebar-toggle { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-wrapper { padding: 0 !important; }
    body { background: white; color: black; }
}
