/* ============================================================
   pbBC Design System — Bootstrap 5 + dedrax-calc inspired
   ============================================================ */

/* ── Design Tokens ── */
:root {
    --primary: #023F87;          /* PostBank blue */
    --primary-light: #1e88e5;
    --primary-dark: #012b5e;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --sidebar-bg: #023F87;
    --sidebar-text: rgba(255,255,255,0.75);
    --sidebar-active: #ffffff;
    --text: #212121;
    --text-secondary: #616161;
    --border: #e0e0e0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --sb-collapsed: 54px;
    --sb-expanded: 200px;
    --transition-speed: 0.2s;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    margin: 0;
}

/* ── App Layout (sidebar + content) ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ═══════════ SIDEBAR ═══════════ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sb-collapsed);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    z-index: 1030;
    overflow: hidden;
    transition: width var(--transition-speed) ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.25);
}
.sidebar.expanded { width: var(--sb-expanded); }

/* Hamburger */
.sb-hamburger {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; width: 100%; height: 42px; padding: 0; flex-shrink: 0;
    background: none; border: none; cursor: pointer;
    transition: background 0.15s;
}
.sb-hamburger:hover { background: rgba(255,255,255,0.12); }
.sb-ham-line {
    display: block; width: 18px; height: 2px;
    background: var(--sidebar-text); border-radius: 1px;
    transition: background 0.15s, transform 0.2s, opacity 0.2s;
}
.sb-hamburger:hover .sb-ham-line { background: #fff; }
.sidebar.expanded .sb-ham-line:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar.expanded .sb-ham-line:nth-child(2) { opacity: 0; }
.sidebar.expanded .sb-ham-line:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Nav items */
.sb-nav { display: flex; flex-direction: column; }
.sb-item {
    display: flex; align-items: center; gap: 10px;
    height: 40px; padding: 0 7px; margin: 2px 7px; flex-shrink: 0;
    border-radius: 6px; border-left: 3px solid transparent; border-right: 3px solid transparent;
    color: var(--sidebar-text); text-decoration: none; font-size: 0.82rem;
    white-space: nowrap; overflow: hidden;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar.expanded .sb-item { justify-content: flex-start; padding: 0 10px; }
.sb-item:hover { background: rgba(255,255,255,0.12); color: #ffffff; }
.sb-item.active {
    background: rgba(255,255,255,0.18);
    color: var(--sidebar-active);
    border-left-color: rgba(255,255,255,0.5); border-right-color: rgba(255,255,255,0.5);
}
.sb-icon {
    flex-shrink: 0; width: 24px; text-align: center;
    font-size: 1.1rem; line-height: 1;
}
.sb-label { display: none; font-size: 0.8rem; font-weight: 500; }
.sidebar.expanded .sb-label { display: inline; }

/* Separator */
.sb-sep { display: block; border: none; width: 32px; height: 3px; border-radius: 2px; background: rgba(255,255,255,0.5); margin: 8px auto; align-self: center; flex-shrink: 0; }

/* User badge */
.sb-user-badge {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: rgba(0,0,0,0.25); color: rgba(255,255,255,0.8);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 600;
    align-self: center; margin: 6px 0 2px;
}
.sb-user-email {
    display: none;
    color: rgba(255,255,255,0.5); font-size: 0.65rem; text-align: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    padding: 0 8px;
    max-width: var(--sb-expanded);
}
.sidebar.expanded .sb-user-email { display: block; }

/* ═══════════ MAIN CONTENT ═══════════ */
.main-content {
    margin-left: var(--sb-collapsed);
    flex: 1;
    transition: margin-left var(--transition-speed) ease;
    padding: 20px 24px;
    min-height: 100vh;
    max-width: 100%;
    overflow-x: auto;
}
.sidebar.expanded ~ .main-content { margin-left: var(--sb-expanded); }

/* Page header */
.page-header {
    padding-bottom: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.page-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

/* ═══════════ PANELS / CARDS ═══════════ */
.panel, .card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 16px;
}
.panel-header, .card-header {
    background: #fafafa;
    padding: 8px 14px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-body, .card-body { padding: 14px; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 0; }

/* Login card centering */
.login-panel {
    max-width: 420px;
    margin: 10% auto 0;
}
.login-panel .card-header {
    font-size: 1.1rem;
    text-align: center;
    font-weight: 700;
}

/* ═══════════ TABLES ═══════════ */
.table {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    font-size: 0.85rem;
}
.table th {
    background: #fafafa;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    border-bottom: 2px solid var(--border);
    padding: 10px 12px;
    vertical-align: middle;
}
.table td {
    padding: 8px 12px;
    vertical-align: middle;
    border-bottom: 1px solid #eee;
}
.table tbody tr:hover { background: #f8f9fa; }
.table th .sort-header { color: var(--primary); text-decoration: none; white-space: nowrap; }
.table th .sort-header:hover { color: var(--primary-dark); text-decoration: underline; }

/* Approval table */
.table-approve { font-size: 0.82rem; }
.table-approve td { height: auto; padding: 6px 8px; }

/* ═══════════ FORMS ═══════════ */
.form-control {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 8px 12px;
    font-size: 0.88rem;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(2, 63, 135, 0.15);
    background: var(--surface);
}
/* Only show validation styling after form submission */
form:not(.was-validated) .form-control.is-invalid {
    border-color: var(--border);
    box-shadow: none;
}
form:not(.was-validated) .invalid-feedback {
    display: none;
}
.form-control.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15);
}
select option[value=""] {
    color: var(--text-secondary);
    font-style: italic;
}
.form-select:disabled {
    opacity: 0.5;
    background: #e9ecef;
    cursor: not-allowed;
}
.form-select {
    border: 1px solid var(--primary);
    border-radius: 4px;
    background: linear-gradient(180deg, #f5f8fc 0%, #d6e2f0 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
    padding: 8px 36px 8px 12px;
    font-size: 0.88rem;
    cursor: pointer;
    appearance: auto;
}
.form-select.is-invalid,
.form-select.is-invalid:not([multiple]):not([size]),
.was-validated .form-select:invalid {
    background: linear-gradient(180deg, #f5f8fc 0%, #d6e2f0 100%) !important;
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15);
}
.form-select:focus {
    border-color: var(--primary-dark);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 0 0 2px rgba(2, 63, 135, 0.15);
}
.form-label, .col-form-label {
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 500;
}
.form-text { font-size: 0.75rem; font-style: italic; color: var(--text-secondary); }
.help-block { font-size: 0.75rem; font-style: italic; color: var(--text-secondary); }
.invalid-feedback { font-size: 0.78rem; }

/* ═══════════ BUTTONS ═══════════ */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: #2e7d32; border-color: #2e7d32; }
.btn-success:hover { background: #1b5e20; border-color: #1b5e20; }
.btn-warning { background: #ef6c00; border-color: #ef6c00; color: #fff; }
.btn-warning:hover { background: #e65100; border-color: #e65100; color: #fff; }

/* ═══════════ ALERTS ═══════════ */
.alert { font-size: 0.85rem; border-radius: var(--radius); }

/* ═══════════ PAGINATION ═══════════ */
.pagination { font-size: 0.85rem; }
.pagination .page-link { color: var(--primary); }
.pagination .active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 700;
}

/* ═══════════ MODALS ═══════════ */
.modal-content { border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* ═══════════ UTILITIES ═══════════ */
.summary { font-size: 0.82rem; line-height: 1.4; }
.center-row { display: table; }
.center { display: table-cell; vertical-align: middle; float: none; margin: 0 auto; width: 100%; }
.text-primary { color: var(--primary) !important; }
.bg-light { background: var(--bg) !important; }

/* ═══════════ BADGES ═══════════ */
.badge-status { font-size: 0.72rem; padding: 3px 8px; border-radius: 12px; font-weight: 500; }
.badge-pending { background: #fff3e0; color: #e65100; }
.badge-approved { background: #e3f2fd; color: #1565c0; }
.badge-prepress { background: #f3e5f5; color: #7b1fa2; }
.badge-printing { background: #e8f5e9; color: #2e7d32; }
.badge-completed { background: #e0e0e0; color: #424242; }

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 768px) {
    .main-content { padding: 12px; }
    .sidebar { width: var(--sb-collapsed); }
    .sidebar.expanded { width: var(--sb-expanded); }
}

/* ============================================================
   BC CARD PREVIEW (preserved — SVG rendering depends on these)
   ============================================================ */

/* ── Custom Fonts ── */
@font-face {
    font-family: 'NerisBold';
    src: url("/static/fonts/Neris-Bold.otf") format("opentype");
    font-style: normal;
    font-weight: normal;
}

@font-face {
    font-family: 'Neris';
    src: url("/static/fonts/Neris-Regular.otf") format("opentype");
    font-style: normal;
    font-weight: normal;
}

.pbBCBG {
    width: 510px;
    height: 280px;
}

.pbBCEN {
    width: 510px;
    height: 280px;
    margin-top: 20px;
}

.bcCards {
    width: 550px;
    background-color: #ffffff;
}

.infoCentralaSofiq {
    color: #023F87;
    font-weight: 700;
}

#frontTextPositionBG, #frontTextPositionEN {
    padding-left: 50px;
    margin-top: -120px;
}
#frontTextPositionBG foreignObject body,
#frontTextPositionEN foreignObject body {
    background: white;
    margin: 0;
    padding: 0;
}
#frontTextPositionBG p, #frontTextPositionEN p {
    color: #023F87;
    font-size: 12px;
    font-family: 'Neris', sans-serif;
    font-style: normal;
    font-weight: normal;
    background: transparent;
}

.frontApprovePositionBG, .frontApprovePositionEN {
    padding-left: 50px;
    margin-top: -120px;
    color: #023F87;
    font-size: 12px;
    font-family: 'Neris', sans-serif;
    font-style: normal;
    font-weight: normal;
    width: 260px;
    background: transparent;
}

#centralen {
    color: #023F87;
    font-weight: 700;
}

.approveBG {
    display: block;
    width: 510px;
    height: 280px;
    margin: 5px;
}

.approveEN {
    width: 510px;
    height: 280px;
    margin: 5px;
}

#submitApprove {
    margin: 5px 5px 55px 5px;
}

#positionsBG {
    word-wrap: break-word;
    width: 100px;
}

/* Prevent BS5 from scaling SVGs in card previews */
.bcCards svg, .approveBG svg, .approveEN svg { max-width: none; }
