/* ============================================================
   PharmaDoc Hub — Custom Stylesheet v1.0
   Pharma-grade professional UI
   ============================================================ */

/* ── Root variables ─────────────────────────────────────────── */
:root {
    --ph-primary:   #1a3a5c;
    --ph-secondary: #2471a3;
    --ph-accent:    #27ae60;
    --ph-warning:   #e67e22;
    --ph-danger:    #c0392b;
    --ph-light:     #f0f4f8;
    --ph-sidebar:   #0f2542;
    --ph-text:      #2c3e50;
    --ph-border:    #dee2e6;
    --ph-shadow:    0 2px 16px rgba(26,58,92,.08);
    --radius-card:  1rem;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

.ph-body { background: #f0f4f8; }

/* ── Navbar ─────────────────────────────────────────────────── */
.ph-navbar {
    background: linear-gradient(135deg, var(--ph-primary) 0%, #1e4976 100%);
    box-shadow: 0 2px 16px rgba(26,58,92,.25);
    padding: .5rem 0;
    z-index: 1030;
}

.brand-icon {
    width: 36px; height: 36px;
    background: rgba(255,255,255,.15);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: #fff;
    flex-shrink: 0;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.3px;
    line-height: 1.2;
    display: block;
}

.brand-sub {
    font-size: .68rem;
    color: rgba(255,255,255,.65);
    letter-spacing: .3px;
}

.ph-nav-link {
    color: rgba(255,255,255,.8) !important;
    border-radius: 8px;
    padding: .4rem .75rem !important;
    font-size: .875rem;
    font-weight: 500;
    transition: background .2s, color .2s;
}
.ph-nav-link:hover,
.ph-nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,.15);
}

/* Quick search */
.ph-search-bar {
    max-width: 260px;
    background: rgba(255,255,255,.12);
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.2);
}
.ph-search-bar .input-group-text { background: transparent !important; border: 0 !important; }
.ph-search-bar .form-control {
    background: transparent !important;
    border: 0 !important;
    color: #fff !important;
    font-size: .84rem;
}
.ph-search-bar .form-control::placeholder { color: rgba(255,255,255,.55) !important; }
.ph-search-bar .btn { font-size: .84rem; border-radius: 0 24px 24px 0 !important; }

/* User button */
.ph-user-btn { color: rgba(255,255,255,.9) !important; }
.ph-user-btn:hover { color: #fff !important; }

.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.user-name { font-size: .8rem; font-weight: 600; color: #fff; line-height: 1.2; }
.user-dept { font-size: .68rem; color: rgba(255,255,255,.6); line-height: 1; }

/* ── Main layout ────────────────────────────────────────────── */
.ph-main {
    flex: 1;
    padding-top: 0;
}

/* ── Footer ─────────────────────────────────────────────────── */
.ph-footer {
    background: #fff;
    border-top: 1px solid var(--ph-border);
    margin-top: auto;
}
.footer-text {
    font-size: .8rem;
    color: #6c757d;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card { border-radius: var(--radius-card) !important; }

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.04);
    box-shadow: var(--ph-shadow);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(26,58,92,.12);
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ph-primary);
    line-height: 1.1;
}
.stat-label {
    font-size: .72rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 600;
}

/* ── Welcome bar ────────────────────────────────────────────── */
.welcome-bar {
    background: linear-gradient(135deg, var(--ph-primary), var(--ph-secondary));
    box-shadow: var(--ph-shadow);
}
.text-white-75 { color: rgba(255,255,255,.75) !important; }

/* ── Category tiles ─────────────────────────────────────────── */
.cat-tile {
    background: #f8f9fa;
    border: 1px solid transparent;
    transition: all .2s;
}
.cat-tile:hover {
    background: #fff;
    border-color: var(--ph-border);
    box-shadow: var(--ph-shadow);
    transform: translateY(-1px);
}
.cat-tile-name {
    font-size: .8rem;
    line-height: 1.3;
}

/* ── Template cards ─────────────────────────────────────────── */
.tpl-card {
    transition: transform .2s, box-shadow .2s;
    position: relative;
    overflow: hidden;
}
.tpl-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(26,58,92,.13) !important;
}
.tpl-card-bar {
    height: 4px;
    border-radius: 4px;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    margin-top: -1.5rem;
}
.tpl-card-title {
    font-size: .9rem;
    line-height: 1.4;
    color: var(--ph-primary);
}
.tpl-card-preview {
    font-size: .8rem;
    line-height: 1.5;
}

/* ── Template list items ────────────────────────────────────── */
.tpl-list-item { transition: background .15s; }
.tpl-list-item:hover { background: #f8f9fa; }
.tpl-list-icon { opacity: .8; }
.tpl-list-title { font-size: .875rem; }

/* ── Sidebar filters ────────────────────────────────────────── */
.sidebar-section-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #6c757d;
    margin-bottom: .5rem;
}

.active-filter {
    background: rgba(26,58,92,.08) !important;
    color: var(--ph-primary) !important;
    font-weight: 600 !important;
}

/* ── Template body (view page) ──────────────────────────────── */
.template-body {
    white-space: pre-wrap;
    font-family: 'Courier New', Courier, monospace;
    font-size: .84rem;
    line-height: 1.7;
    color: #2c3e50;
    min-height: 200px;
    background: #fafafa;
    border-radius: 0 0 1rem 1rem;
}

/* Unfilled placeholder highlighting */
.template-body .ph-unfilled {
    background: rgba(243, 156, 18, 0.18);
    color: #c87f0a;
    border-radius: 3px;
    padding: 1px 3px;
    font-weight: 600;
    border-bottom: 2px dashed #f39c12;
}

/* Filled placeholder */
.template-body .ph-filled {
    background: rgba(39, 174, 96, 0.15);
    color: #1e7a46;
    border-radius: 3px;
    padding: 1px 3px;
    font-weight: 600;
}

/* ── Copy toast ─────────────────────────────────────────────── */
.copy-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #fff;
    border-radius: 12px;
    padding: .75rem 1.25rem;
    box-shadow: 0 4px 24px rgba(0,0,0,.15);
    font-weight: 600;
    font-size: .875rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    border-left: 4px solid #27ae60;
    animation: fadeInUp .3s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── User avatars ───────────────────────────────────────────── */
.user-avatar-lg {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--ph-primary), var(--ph-secondary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; font-weight: 700; color: #fff;
}

.user-avatar-sm {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--ph-primary), var(--ph-secondary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

/* ── Login page ─────────────────────────────────────────────── */
.login-logo {
    width: 72px; height: 72px;
    background: rgba(255,255,255,.15);
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem; color: #fff;
    margin: 0 auto;
    backdrop-filter: blur(4px);
}
.login-title  { font-size: 1.5rem; font-weight: 700; color: #fff; margin-bottom: .25rem; }
.login-subtitle { font-size: .82rem; color: rgba(255,255,255,.65); }

/* ── Admin stat card link ───────────────────────────────────── */
a .stat-card { color: inherit; }

/* ── Buttons utility ────────────────────────────────────────── */
.btn-xs {
    padding: .2rem .55rem;
    font-size: .75rem;
    line-height: 1.4;
}

/* ── Badge tweaks ───────────────────────────────────────────── */
.badge { font-weight: 600; letter-spacing: .2px; }

/* ── Table enhancements ─────────────────────────────────────── */
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table-light th { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: #6c757d; }

/* ── Card header subtle ─────────────────────────────────────── */
.card-header h6 { font-size: .88rem; }

/* ── Scrollbar styling ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f0f4f8; }
::-webkit-scrollbar-thumb { background: #c8d6e5; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #9fb3c8; }

/* ── PDF print styles ───────────────────────────────────────── */
@media print {
    .ph-navbar, .ph-footer, .card-header, .col-lg-4, .breadcrumb,
    #copyBtn, button, .btn, nav, .alert-info { display: none !important; }
    .col-lg-8 { width: 100% !important; flex: 0 0 100% !important; }
    .ph-main { padding: 0; }
    .template-body {
        font-size: 11pt;
        line-height: 1.6;
        background: white;
        color: black;
    }
    .ph-unfilled { background: none; border: none; color: black; }
    .ph-filled   { background: none; border: none; color: black; }
    body { background: white; }

    .pdf-header {
        text-align: center;
        padding-bottom: .5rem;
        border-bottom: 2px solid #333;
        margin-bottom: 1rem;
        font-size: 11pt;
    }
    .pdf-footer {
        margin-top: 2rem;
        padding-top: .5rem;
        border-top: 1px solid #ccc;
        font-size: 9pt;
        color: #555;
    }
}

/* ── Responsive tweaks ──────────────────────────────────────── */
@media (max-width: 767px) {
    .stat-value { font-size: 1.25rem; }
    .welcome-bar .btn { font-size: .82rem; }
    .template-body { font-size: .78rem; }
    .tpl-card-bar { margin-left: -1.25rem; margin-right: -1.25rem; margin-top: -1.25rem; }
}

@media (max-width: 575px) {
    .ph-navbar .navbar-brand .brand-icon { width: 30px; height: 30px; font-size: 1rem; }
    .brand-name { font-size: .95rem; }
}

/* ── Misc helpers ───────────────────────────────────────────── */
.min-w-0 { min-width: 0; }
.font-monospace { font-family: 'Courier New', Courier, monospace; }
.rounded-top-4 { border-radius: 1rem 1rem 0 0 !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
