/*
 * ============================================================
 * CloudLink Timeclock - shared stylesheet
 * ============================================================
 */

/* -----------------------------------------------------------------
 * Theme variables
 * --------------------------------------------------------------- */
:root {
    --color-brand-dark:        #0a1628;
    --color-brand-dark-hover:  #142339;
    --color-on-dark:           #ffffff;
    --color-on-dark-soft:      #b9c2cf;
    --color-on-dark-muted:     #6e7c91;

    --color-bg:        #f5f7fa;
    --color-surface:   #ffffff;
    --color-text:      #1f2933;
    --color-text-soft: #52606d;
    --color-text-muted:#8493a6;
    --color-border:    #d8e0e8;
    --color-border-soft:#e6ecf2;

    --color-primary:        #1a4480;
    --color-primary-hover:  #143565;
    --color-secondary:      #e9eef4;
    --color-secondary-hover:#d8e0e8;
    --color-danger:         #b00020;
    --color-danger-hover:   #870016;

    --color-error-bg:    #fdecea;
    --color-error-text:  #8b1d1d;
    --color-error-border:#f1b0ac;
    --color-success-bg:  #e6f4ea;
    --color-success-text:#1e6d33;
    --color-warning-bg:  #fff4e0;
    --color-warning-text:#8a5a00;

    --radius: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
}

/* -----------------------------------------------------------------
 * Reset / base
 * --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin-top: 0; }
h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.text-muted { color: var(--color-text-muted); }

/* -----------------------------------------------------------------
 * Admin layout: dark topbar
 * --------------------------------------------------------------- */
.layout-base { min-height: 100vh; }

.topbar {
    background: var(--color-brand-dark);
    color: var(--color-on-dark);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    min-height: 64px;
    flex-wrap: wrap;
}
.topbar-brand { display: flex; align-items: center; }
.topbar-brand-link { display: inline-flex; align-items: center; text-decoration: none; }
.topbar-brand-link:hover { text-decoration: none; }
.topbar-logo { display: block; height: 48px; width: auto; }
.topbar-mainnav { display: flex; align-items: center; gap: 1.5rem; flex: 1; }
.topbar-link {
    color: var(--color-on-dark-soft);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: color 120ms ease, border-color 120ms ease;
}
.topbar-link:hover { color: var(--color-on-dark); text-decoration: none; }
.topbar-link.is-active {
    color: var(--color-on-dark);
    border-bottom-color: var(--color-on-dark);
}
.topbar-user-area {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-left: auto;
}
.topbar-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}
.topbar-user-email {
    color: var(--color-on-dark);
    font-size: 0.9rem;
    font-weight: 500;
}
.topbar-user-role {
    color: var(--color-on-dark-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.1rem;
}
.topbar-logout-form { margin: 0; }
.topbar-logout-btn {
    background: transparent;
    color: var(--color-on-dark);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--radius);
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 120ms ease, border-color 120ms ease;
}
.topbar-logout-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

.main { padding: 2rem 1.25rem; }
.container { max-width: 1200px; margin: 0 auto; }

@media (max-width: 760px) {
    .topbar-inner { gap: 1rem; padding: 0.75rem 1rem; }
    .topbar-mainnav {
        order: 3;
        flex: 0 0 100%;
        gap: 1.25rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    .topbar-user-area { gap: 0.75rem; }
    .topbar-user { align-items: flex-end; }
}

/* -----------------------------------------------------------------
 * Auth layout (login / change password)
 * --------------------------------------------------------------- */
.layout-auth { min-height: 100vh; display: flex; background: var(--color-bg); }
.auth-main {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.auth-card {
    width: 100%;
    max-width: 480px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.auth-card-header {
    background: var(--color-brand-dark);
    padding: 2rem 1.5rem;
    text-align: center;
}
.auth-logo {
    display: block;
    max-width: 312px;
    width: 100%;
    height: auto;
    margin: 0 auto;
}
.auth-card-body { padding: 2rem 2rem; }
.auth-subtitle {
    margin-top: 0;
    margin-bottom: 1.25rem;
    text-align: center;
    font-size: 1.4rem;
    color: var(--color-text);
}
.auth-help { color: var(--color-text-soft); font-size: 0.95rem; margin-bottom: 1rem; }
.auth-title { display: none; }

/* -----------------------------------------------------------------
 * Employee layout
 * --------------------------------------------------------------- */
.layout-employee {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
}
.employee-header {
    background: var(--color-brand-dark);
    padding: 0.85rem 1rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.employee-header-logo { display: inline-block; height: 40px; width: auto; }

.employee-main {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
}
.employee-container { width: 100%; max-width: 460px; }

.employee-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.75rem 1.5rem;
    text-align: center;
}
.employee-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.employee-photo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    background: #ddd;
}
.employee-photo-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    font-size: 2rem;
    letter-spacing: 0.05em;
}
.employee-name { margin: 0; font-size: 1.4rem; font-weight: 600; }

.employee-qr-section { margin-bottom: 1rem; }
.employee-instruction { margin: 0 0 1rem; color: var(--color-text-soft); font-size: 0.95rem; }

/* The actual QR image - centred, with a tiny bit of padding so it
   doesn't touch the edge of the card */
.employee-qr {
    display: block;
    width: 280px;
    max-width: 100%;
    height: auto;
    margin: 0 auto 1rem;
    border-radius: var(--radius);
    background: #fff;
}
.employee-qr-actions {
    margin: 0 0 1rem;
}
.employee-qr-hint { margin: 0; color: var(--color-text-muted); font-size: 0.85rem; }

.employee-last-login {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-soft);
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.employee-footer { padding: 1rem; text-align: center; }
.employee-logout-form { margin: 0; }

/* -----------------------------------------------------------------
 * Admin QR section (on the employee edit page)
 * --------------------------------------------------------------- */
.admin-qr-block {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}
.admin-qr-img {
    display: block;
    width: 220px;
    height: 220px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
}
.admin-qr-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* -----------------------------------------------------------------
 * Forms
 * --------------------------------------------------------------- */
.form-row { margin-bottom: 1rem; }
.form-row:last-child { margin-bottom: 0; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0 1rem;
}
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.form-checkbox-row { display: flex; }
.form-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--color-text);
    cursor: pointer;
}
.form-checkbox input { transform: translateY(1px); }

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--color-text);
}
.form-input {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 1rem;
    line-height: 1.4;
    background: #fff;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color 120ms ease, box-shadow 120ms ease;
    font-family: inherit;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 68, 128, 0.15);
}
.form-input.is-error { border-color: var(--color-danger); }
.form-hint {
    display: block;
    margin-top: 0.3rem;
    color: var(--color-text-soft);
    font-size: 0.85rem;
}
.form-error {
    display: block;
    margin-top: 0.3rem;
    color: var(--color-danger);
    font-size: 0.85rem;
}

.password-field { display: flex; gap: 0.5rem; align-items: stretch; }
.password-field .form-input { flex: 1; }
.password-toggle { align-self: stretch; padding: 0.55rem 0.75rem; }

.current-photo {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* -----------------------------------------------------------------
 * Buttons
 * --------------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 0.55rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
    text-decoration: none;
    line-height: 1.3;
    font-family: inherit;
}
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); text-decoration: none; }
.btn-secondary {
    background: var(--color-secondary);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-secondary-hover); text-decoration: none; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-hover); text-decoration: none; }
.btn-block { display: block; width: 100%; }

.btn-link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--color-primary);
    cursor: pointer;
    font: inherit;
}
.btn-link:hover { text-decoration: underline; }

.inline-form { display: inline-block; margin: 0; }

/* -----------------------------------------------------------------
 * Alerts
 * --------------------------------------------------------------- */
.alert {
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
    border: 1px solid;
}
.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
    border-color: var(--color-error-border);
}
.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border-color: rgba(30, 109, 51, 0.25);
}

/* -----------------------------------------------------------------
 * Page headers
 * --------------------------------------------------------------- */
.page-header { margin-bottom: 1.5rem; }
.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-subtitle { color: var(--color-text-soft); margin: 0.25rem 0 0; }

/* -----------------------------------------------------------------
 * Cards and stats
 * --------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.card h2:first-child { margin-top: 0; }
.card-table { padding: 0; overflow: hidden; }
.card-danger { border-color: rgba(176, 0, 32, 0.4); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}
.stat-label {
    color: var(--color-text-soft);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat-value { font-size: 2rem; font-weight: 600; margin-top: 0.25rem; }

/* -----------------------------------------------------------------
 * Tables
 * --------------------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.data-table th {
    text-align: left;
    background: #fafbfd;
    color: var(--color-text-soft);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
}
.data-table td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border-soft);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.is-inactive td { opacity: 0.6; }
.data-table .actions-col { text-align: right; white-space: nowrap; }
.data-table .actions-col .btn { margin-left: 0.25rem; }
.data-table .avatar-col { width: 56px; }

/* -----------------------------------------------------------------
 * Avatars
 * --------------------------------------------------------------- */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    background: #888;
    flex-shrink: 0;
}
.avatar-photo { object-fit: cover; }
.avatar-large { width: 80px; height: 80px; font-size: 1.5rem; }

/* -----------------------------------------------------------------
 * Badges
 * --------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 999px;
    border: 1px solid transparent;
}
.badge-active { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-inactive { background: #eef0f3; color: var(--color-text-soft); }
.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    margin-left: 0.25rem;
}

/* -----------------------------------------------------------------
 * Misc
 * --------------------------------------------------------------- */
.placeholder-text { color: var(--color-text-soft); font-style: italic; }

@media (max-width: 720px) {
    .data-table th, .data-table td { padding: 0.5rem 0.5rem; }
    .data-table .actions-col { text-align: left; }
}
