/* iTOP mobile — single global stylesheet (per project standard) */

:root {
    --brand: #0078d7;
    --brand-dark: #005a9e;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1c1c1e;
    --muted: #6b6f76;
    --border: #e3e5ea;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);

    --status-new: #1e88e5;
    --status-assigned: #6a1b9a;
    --status-pending: #f9a825;
    --status-escalated: #d32f2f;
    --status-resolved: #2e7d32;
    --status-default: #455a64;

    --hit: 48px;
    --radius: 10px;
    --gap: 12px;
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overscroll-behavior-y: contain;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
    background: var(--brand);
    color: #fff;
    box-shadow: var(--shadow);
}

.brand {
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 1.1rem;
}
.brand span { font-weight: 300; opacity: 0.85; }

.logout-form { margin: 0; }
.icon-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 8px 12px;
    border-radius: var(--radius);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.icon-btn .user { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn .logout-icon { font-weight: 700; }

.content {
    flex: 1;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.page-header h1 { flex: 1; }
.page-header .back { font-size: 0.95rem; }

.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--hit);
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary {
    background: var(--brand);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-primary:disabled { background: #b0bec5; cursor: not-allowed; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:disabled { color: var(--muted); cursor: not-allowed; }

.btn-sm { min-height: 40px; padding: 6px 14px; font-size: 0.9rem; }

.button-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.field {
    display: block;
    margin-bottom: 14px;
}
.field > span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}
.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.field-label-row > span {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}
.field .optional,
.field-label-row .optional {
    font-style: normal;
    font-weight: 400;
    color: var(--muted);
    font-size: 0.8em;
    margin-left: 4px;
    opacity: 0.7;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    color: var(--brand);
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 30px;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.link-btn:hover:not(:disabled) {
    background: rgba(0, 120, 215, 0.08);
    border-color: rgba(0, 120, 215, 0.15);
}
.link-btn:disabled {
    color: var(--muted);
    cursor: not-allowed;
    opacity: 0.55;
}
.link-btn svg { flex-shrink: 0; }
.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: var(--hit);
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    background: var(--surface);
    color: var(--text);
}
.field textarea {
    min-height: 120px;
    resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.alert {
    background: #fdecea;
    color: #b71c1c;
    border: 1px solid #f5c6cb;
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 14px;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 16px;
}
.empty .hint { font-size: 0.85rem; }

.ticket-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ticket-card {
    display: block;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    color: var(--text);
    border-left: 4px solid var(--status-default);
}
.ticket-card:active { transform: scale(0.99); }

.ticket-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.85rem;
}
.ticket-card .ref { color: var(--muted); font-weight: 600; }
.ticket-card .title {
    font-weight: 600;
    margin: 4px 0 6px;
    line-height: 1.3;
}
.ticket-card .meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--muted);
}

.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #fff;
}
.status-new { background: var(--status-new); }
.status-assigned { background: var(--status-assigned); }
.status-pending { background: var(--status-pending); color: #1c1c1e; }
.status-escalated { background: var(--status-escalated); }
.status-resolved { background: var(--status-resolved); }
.status-default { background: var(--status-default); }

.ticket-detail header {
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}
.ticket-detail .ref-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
}
.meta-list {
    margin: 12px 0 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}
.meta-list > div {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px;
    font-size: 0.9rem;
}
.meta-list dt { color: var(--muted); margin: 0; }
.meta-list dd { margin: 0; font-weight: 500; }

.description {
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}
.description .rich {
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
}
.description .rich img { max-width: 100%; height: auto; }
.description .rich table { width: 100%; }

.action-card {
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-card {
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ─── Login screen ───────────────────────────────────────── */

.login-shell {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background: radial-gradient(at 20% 20%, #0a2540 0%, #051527 60%, #020a14 100%);
    isolation: isolate;
}

/* Animated blob mesh behind the card */
.login-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}
.login-bg .blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    animation: float 18s ease-in-out infinite;
}
.login-bg .blob-1 { width: 380px; height: 380px; top: -120px; left: -100px; background: #0078d7; }
.login-bg .blob-2 { width: 320px; height: 320px; bottom: -140px; right: -120px; background: #00b4d8; animation-delay: -6s; animation-duration: 22s; }
.login-bg .blob-3 { width: 260px; height: 260px; top: 40%; left: 50%; transform: translate(-50%, -50%); background: #5a3fd1; opacity: 0.4; animation-delay: -12s; animation-duration: 26s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(40px, -30px) scale(1.08); }
    66%      { transform: translate(-30px, 40px) scale(0.95); }
}
.login-bg .blob-3 {
    /* keep centered while floating */
    animation-name: float-c;
}
@keyframes float-c {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    33%      { transform: translate(-30%, -60%) scale(1.1); }
    66%      { transform: translate(-70%, -40%) scale(0.92); }
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    padding: 32px 26px 24px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        0 20px 50px rgba(0, 30, 60, 0.35),
        0 1px 0 rgba(255, 255, 255, 0.6) inset;
    animation: card-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.brand-mark {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}
.brand-mark svg {
    filter: drop-shadow(0 6px 14px rgba(0, 120, 215, 0.35));
    animation: mark-in 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 80ms;
}
@keyframes mark-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.login-title {
    font-size: 1.8rem;
    color: var(--text);
    text-align: center;
    margin: 0 0 4px;
    letter-spacing: -0.4px;
}
.login-title span {
    font-weight: 300;
    color: var(--brand);
}
.login-subtitle {
    text-align: center;
    color: var(--muted);
    margin: 0 0 22px;
    font-size: 0.92rem;
}

.login-form .field { margin-bottom: 14px; }
.login-form .field > label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.2px;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrap .input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--muted);
    pointer-events: none;
    transition: color 0.15s ease;
}
.input-wrap input {
    width: 100%;
    min-height: var(--hit);
    padding: 12px 14px 12px 44px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-wrap input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(0, 120, 215, 0.15);
}
.input-wrap input:focus + .reveal,
.input-wrap:focus-within .input-icon {
    color: var(--brand);
}

.reveal {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.reveal:hover { color: var(--brand); background: rgba(0, 120, 215, 0.08); }
.reveal svg { width: 18px; height: 18px; }
.reveal .eye-on { display: none; }
.reveal.on .eye-off { display: none; }
.reveal.on .eye-on  { display: block; }

.btn-signin {
    width: 100%;
    margin-top: 8px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    box-shadow: 0 8px 18px rgba(0, 120, 215, 0.35);
    transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
    gap: 8px;
}
.btn-signin svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}
.btn-signin:hover:not(:disabled) {
    filter: brightness(1.05);
    box-shadow: 0 10px 24px rgba(0, 120, 215, 0.45);
}
.btn-signin:hover:not(:disabled) svg { transform: translateX(3px); }
.btn-signin:active:not(:disabled)   { transform: translateY(1px); box-shadow: 0 5px 12px rgba(0, 120, 215, 0.3); }

.login-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.75rem;
    margin: 22px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.login-footer a { color: var(--brand); font-weight: 600; }
.login-footer .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2e7d32;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.18);
}

/* Error pill on the login card — more prominent than the generic .alert */
.login-card .alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff4f3;
    color: #a01818;
    border: 1px solid #f3c2bf;
    border-left: 4px solid #d32f2f;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    line-height: 1.35;
}
.login-card .alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-shake { animation: shake 380ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
    .login-bg .blob,
    .login-card,
    .brand-mark svg,
    .alert-shake,
    .btn-signin,
    .btn-signin svg {
        animation: none !important;
        transition: none !important;
    }
}

@media (min-width: 600px) {
    h1 { font-size: 1.55rem; }
    .meta-list { grid-template-columns: 1fr 1fr; }
    .meta-list > div { grid-template-columns: 130px 1fr; }
    .button-row { flex-direction: row; }
    .button-row .btn-primary,
    .button-row .btn-secondary { flex: 1; }
}
