/* =====================================================
   HES ID by Patryk — Stylesheet
   assets/style.css
   ===================================================== */

/* ── Google Fonts loaded in HTML ── */

/* ── CSS Variables ── */
:root {
    --navy:        #1a3a5c;
    --navy-light:  #234f7d;
    --navy-dark:   #102438;
    --gold:        #c8a84b;
    --gold-light:  #e0c16a;
    --gold-dark:   #a08030;
    --white:       #ffffff;
    --bg:          #f0f4f8;
    --bg-card:     #ffffff;
    --border:      #dde3ea;
    --text:        #1e2a38;
    --text-muted:  #6b7a90;
    --red:         #d93025;
    --red-light:   #fce8e6;
    --green:       #1e7e34;
    --green-light: #d4edda;

    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   16px;
    --radius-xl:   24px;

    --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
    --shadow-md:   0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:   0 8px 32px rgba(0,0,0,.12);

    --font-sans:   'DM Sans', system-ui, sans-serif;
    --font-serif:  'DM Serif Display', Georgia, serif;

    --transition:  0.18s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text); min-height: 100vh; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button, input, textarea { font-family: inherit; }


/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f2340 0%, #1a3a5c 50%, #0f2340 100%);
    padding: 24px;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0,0,0,.30);
}

/* Brand inside login */
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.login-logo-mark { flex-shrink: 0; }

.login-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.login-brand-main {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--navy);
    letter-spacing: .5px;
}

.login-brand-sub {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.login-divider {
    height: 2px;
    background: linear-gradient(90deg, var(--gold), transparent);
    margin-bottom: 24px;
    border-radius: 2px;
}

.login-heading {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.login-subheading {
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-footer {
    font-size: .75rem;
    color: rgba(255,255,255,.4);
}


/* ============================================================
   APP LAYOUT
   ============================================================ */

.app-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ── */
.app-header {
    background: var(--navy);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,.18);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo-mark { flex-shrink: 0; }

.header-brand-main {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--white);
    letter-spacing: .5px;
}

.header-brand-sub {
    font-size: .7rem;
    color: rgba(255,255,255,.5);
    font-weight: 400;
    letter-spacing: .5px;
    text-transform: uppercase;
    margin-left: 4px;
}


/* isWeb Cloud logo in header */
.header-isweb-logo {
    height: 28px;
    width: auto;
    display: block;
    /* logo has black bg — invert to show on dark navy header */
    filter: brightness(0) invert(1);
}
/* ── Main ── */
.app-main {
    flex: 1;
    padding: 32px 24px;
}

.app-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 28px;
    align-items: start;
}

/* ── Footer ── */
.app-footer {
    text-align: center;
    padding: 20px;
    font-size: .78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--white);
}


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

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

.panel-header {
    padding: 24px 28px 0;
}

.panel-title {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
}

.panel-subtitle {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Editor panel */
.editor-panel { padding-bottom: 28px; }
.editor-panel form { padding: 20px 28px 0; }

/* Preview panel */
.preview-panel { padding: 0 0 28px; }

.preview-stage {
    padding: 24px 28px 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}


/* ============================================================
   FORM ELEMENTS
   ============================================================ */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: .2px;
}

.required {
    color: var(--red);
    margin-left: 2px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: .9rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--navy);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(26,58,92,.10);
}

.form-input.is-invalid {
    border-color: var(--red);
    background: #fff9f9;
}

.form-input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(217,48,37,.10);
}

.field-error {
    font-size: .78rem;
    color: var(--red);
    margin-top: 4px;
    min-height: 18px;
}

.form-actions {
    padding-top: 8px;
}


/* ── Photo Upload ── */
.upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    min-height: 120px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    overflow: hidden;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--navy);
    background: #eef3f9;
}

.upload-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 8px;
    pointer-events: none;
}

.upload-icon { color: var(--text-muted); }

.upload-text {
    font-size: .85rem;
    font-weight: 500;
    color: var(--navy);
}

.upload-hint {
    font-size: .75rem;
    color: var(--text-muted);
}

/* Preview inside upload area */
.upload-preview-wrap {
    position: relative;
    width: 100%;
    text-align: center;
    padding: 12px;
    pointer-events: none;
}

.upload-preview-img {
    max-height: 160px;
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 0 auto;
    object-fit: cover;
    display: block;
}

.upload-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    z-index: 3;
    transition: background var(--transition);
}

.upload-remove-btn:hover { background: var(--red); }


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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), box-shadow var(--transition),
                transform var(--transition);
    white-space: nowrap;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}

.btn-primary:hover:not(:disabled) {
    background: var(--navy-light);
    border-color: var(--navy-light);
    box-shadow: 0 4px 14px rgba(26,58,92,.35);
}

.btn-ghost {
    background: transparent;
    color: rgba(255,255,255,.85);
    border-color: rgba(255,255,255,.2);
}

.btn-ghost:hover {
    background: rgba(255,255,255,.1);
    color: var(--white);
}

.btn-full { width: 100%; }

.btn-lg {
    padding: 13px 24px;
    font-size: .95rem;
}

.btn-sm {
    padding: 7px 14px;
    font-size: .8rem;
}


/* ============================================================
   ALERTS / NOTIFICATIONS
   ============================================================ */

.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid rgba(217,48,37,.2);
}

.notification {
    margin: 16px 0 0;
    /* shown/hidden by JS */
}

.notification:empty { display: none; }

.notification.success {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--green-light);
    color: var(--green);
    border: 1px solid rgba(30,126,52,.2);
    border-radius: var(--radius-md);
    font-size: .87rem;
    font-weight: 500;
}

.notification.error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--red-light);
    color: var(--red);
    border: 1px solid rgba(217,48,37,.2);
    border-radius: var(--radius-md);
    font-size: .87rem;
    font-weight: 500;
}


/* ============================================================
   ID CARD
   ============================================================ */

/* The card scales to fit within the preview panel.
   Actual fixed aspect: roughly 3.375 × 2.125 inches → ~1.588:1 ratio.
   We use a specific px size and scale it down if needed. */

.id-card {
    width: 500px;
    background: #f5f6f8;
    border-radius: 14px;
    border: 1.5px solid #d0d5de;
    box-shadow: 0 6px 28px rgba(0,0,0,.15), 0 1px 4px rgba(0,0,0,.08);
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif; /* match real ID card feel */
    user-select: none;

    /* Scale down to fit the panel on smaller screens */
    max-width: 100%;
    transform-origin: top left;
}

/* ── Top title bar ── */
.card-title-bar {
    background: var(--white);
    text-align: center;
    padding: 10px 16px 8px;
    border-bottom: 2px solid var(--border);
}

.card-company-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: .3px;
}

/* ── Upper content: logos + photo ── */
.card-upper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    gap: 12px;
    background: var(--white);
}

/* Logos column */
.card-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex: 1;
    padding-right: 0;
    margin-left: 8px;
}

.card-logo-slot {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-logo-img {
    object-fit: contain;
    display: block;
}

/* HES logo — compact emblem */
#hesLogoSlot .card-logo-img { height: 82px; width: auto; max-width: 82px; }
/* NHS logo — large, dominant */
#nhsLogoSlot .card-logo-img { height: 76px; width: auto; max-width: 170px; }

.card-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 800;
    font-size: .85rem;
    letter-spacing: 1px;
}

/* HES fallback style */
#hesLogoFallback {
    width: 60px;
    height: 60px;
    background: #e8edf3;
    color: var(--navy);
    border: 2px solid var(--border);
}

.nhs-fallback {
    width: 80px;
    height: 48px;
    background: #005eb8;
    color: white;
    border-radius: 4px;
}

.nhs-text { color: white; }

/* Employee photo */
.card-photo-slot {
    width: 100px;
    height: 120px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--border);
    background: #e0e7ef;
    flex-shrink: 0;
}

.card-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
}

/* ── Name area ── */
.card-name-area {
    text-align: center;
    padding: 10px 18px 8px;
    background: var(--white);
}

.card-employee-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: .2px;
    display: block;
    line-height: 1.2;
}

/* ── Gold bar ── */
.card-gold-bar {
    height: 14px;
    background: linear-gradient(90deg, #b8892a 0%, #e8c55a 30%, #f0d070 50%, #e8c55a 70%, #b8892a 100%);
    margin: 0;
    box-shadow: inset 0 1px 2px rgba(255,255,255,.4), inset 0 -1px 2px rgba(0,0,0,.2);
}

/* ── Position ── */
.card-position-area {
    text-align: center;
    padding: 8px 18px 6px;
    background: var(--white);
}

.card-position-text {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: .3px;
    display: block;
}

/* ── Footer verification text ── */
.card-footer-text {
    text-align: center;
    padding: 8px 18px 12px;
    font-size: .67rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: .3px;
    line-height: 1.5;
    background: var(--white);
    border-top: 1px solid var(--border);
    text-transform: uppercase;
}


/* ============================================================
   LOADING SPINNER on button
   ============================================================ */

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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


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

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .app-main { padding: 20px 16px; }
}

@media (max-width: 560px) {
    .login-card { padding: 28px 20px; }
    .editor-panel form, .panel-header { padding-left: 20px; padding-right: 20px; }
    .preview-stage { padding: 16px 12px 0; }

    .id-card {
        width: 100%;
        font-size: 13px;
    }

    .card-employee-name { font-size: 1rem; }
    #hesLogoSlot .card-logo-img { height: 56px !important; max-width: 56px !important; }
    #nhsLogoSlot .card-logo-img { height: 52px !important; max-width: 120px !important; }
    .card-photo-slot { width: 76px; height: 92px; }
}
