/* Gmail-inspired admin UI */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@400;500;600&family=Roboto:wght@400;500&display=swap');

:root {
    --bg: #f6f8fc;
    --surface: #ffffff;
    --border: #dadce0;
    --border-light: #e8eaed;
    --text: #202124;
    --text-secondary: #5f6368;
    --primary: #1a73e8;
    --primary-hover: #1765cc;
    --primary-soft: #e8f0fe;
    --brand: #c00000;
    --brand-soft: #fce8e6;
    --danger: #d93025;
    --danger-soft: #fce8e6;
    --shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    --radius: 8px;
    --sidebar-width: 256px;
}

* {
    box-sizing: border-box;
}

body.hv-admin {
    margin: 0;
    font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

/* ── Login page ── */
.login-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-brand .logo-mark {
    width: 48px;
    height: 48px;
    background: var(--brand);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    margin-bottom: 12px;
}

.login-brand h1 {
    margin: 0;
    font-family: 'Google Sans Flex', 'Roboto', sans-serif;
    font-size: 24px;
    font-weight: 400;
    color: var(--text);
}

.login-brand p {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 48px 40px 36px;
    width: 100%;
    max-width: 450px;
}

.login-card h2 {
    margin: 0 0 8px;
    font-family: 'Google Sans Flex', 'Roboto', sans-serif;
    font-size: 24px;
    font-weight: 400;
}

.login-card .subtitle {
    margin: 0 0 32px;
    color: var(--text-secondary);
    font-size: 16px;
}

.login-card label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.login-card input[type="text"],
.login-card input[type="password"],
.login-card .password-field input {
    width: 100%;
    padding: 13px 15px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.2s;
}

.password-field {
    position: relative;
    margin-bottom: 24px;
}

.password-field input {
    margin-bottom: 0;
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.password-toggle:hover {
    background: rgba(60, 64, 67, 0.08);
    color: var(--text);
}

.login-card input:focus,
.login-card .password-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.login-card .btn-primary {
    width: 100%;
    padding: 12px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.login-card .btn-primary:hover {
    background: var(--primary-hover);
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
}

.login-footer a {
    color: var(--primary);
    font-weight: 500;
}

/* ── App shell (authenticated) ── */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 0 8px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 20px;
    display: none;
}

.menu-btn:hover {
    background: rgba(60, 64, 67, 0.08);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.app-logo .logo-icon {
    width: 32px;
    height: 32px;
    background: var(--brand);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
}

.app-logo span {
    font-family: 'Google Sans Flex', 'Roboto', sans-serif;
    font-size: 22px;
    font-weight: 400;
    letter-spacing: -0.2px;
}

.topbar-search {
    flex: 1;
    max-width: 720px;
    margin: 0 24px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: 24px;
    padding: 0 16px;
    height: 48px;
    border: 1px solid transparent;
    transition: background 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
    background: var(--surface);
    box-shadow: var(--shadow);
    border-color: var(--border-light);
}

.search-box .search-icon {
    color: var(--text-secondary);
    margin-right: 12px;
    font-size: 18px;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--text);
    outline: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 4px 4px;
    border-radius: 24px;
    cursor: default;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
}

.user-name {
    font-size: 14px;
    color: var(--text);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-text {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-text:hover {
    background: rgba(26, 115, 232, 0.08);
    color: var(--primary-hover);
}

.app-body {
    display: flex;
    flex: 1;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border-light);
    padding: 8px 12px;
    flex-shrink: 0;
}

.compose-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: calc(100% - 8px);
    margin: 8px 4px 16px;
    padding: 0 24px;
    height: 56px;
    border: none;
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.compose-btn:hover {
    box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
}

.compose-btn-icon {
    font-size: 18px;
    color: var(--text-secondary);
}

.compose-btn-inline {
    width: auto;
    height: 40px;
    margin: 0;
    padding: 0 20px;
    border-radius: 20px;
}

.compose-btn-empty {
    width: auto;
    height: 44px;
    margin: 20px auto 0;
    padding: 0 24px;
    border-radius: 22px;
}

.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}

.flash-success {
    background: #e6f4ea;
    color: #137333;
    border: 1px solid #ceead6;
}

.flash-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #f6aea9;
}

/* Compose panel */
.compose-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(32, 33, 36, 0.4);
    z-index: 200;
}

.compose-backdrop.open {
    display: block;
}

.compose-panel {
    display: none;
    position: fixed;
    right: 24px;
    bottom: 0;
    width: 520px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
    z-index: 201;
    flex-direction: column;
    max-height: 90vh;
}

.compose-panel.open {
    display: flex;
}

.compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #404040;
    color: #fff;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
    font-weight: 500;
}

.compose-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.compose-body {
    padding: 8px 16px 16px;
    overflow-y: auto;
    flex: 1;
}

.compose-field {
    border-bottom: 1px solid var(--border-light);
    padding: 8px 0;
}

.compose-field label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.compose-field input,
.compose-field textarea {
    width: 100%;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: transparent;
    resize: vertical;
    min-height: 24px;
}

.compose-field textarea {
    min-height: 160px;
    padding-top: 4px;
}

.compose-options {
    padding: 12px 0 4px;
}

.compose-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.compose-email-only,
.compose-twilio-only {
    display: none;
}

.compose-hint {
    font-size: 12px;
    color: var(--text-secondary);
    padding-top: 8px;
}

.compose-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
}

.btn-send {
    padding: 10px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.btn-send:hover {
    background: var(--primary-hover);
}

.btn-cancel {
    padding: 10px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-size: 14px;
    cursor: pointer;
}

.btn-cancel:hover {
    color: var(--text);
}

@media (max-width: 900px) {
    .compose-panel {
        right: 0;
        left: 0;
        width: auto;
        max-width: none;
    }

    .page-header-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

.sidebar-section {
    margin-bottom: 16px;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 8px 12px 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px 0 16px;
    height: 32px;
    border-radius: 0 16px 16px 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 2px;
    transition: background 0.15s;
}

.sidebar-nav a:hover {
    background: rgba(60, 64, 67, 0.08);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-nav a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 18px;
    opacity: 0.85;
}

.sidebar-nav a.active .nav-icon {
    opacity: 1;
}

.main-content {
    flex: 1;
    padding: 16px 24px 32px;
    min-width: 0;
}

.page-header {
    margin-bottom: 16px;
}

.page-header h1 {
    margin: 0;
    font-family: 'Google Sans Flex', 'Roboto', sans-serif;
    font-size: 22px;
    font-weight: 400;
    color: var(--text);
}

.page-header .page-meta {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.content-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
}

.content-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--surface);
}

.content-toolbar .record-count {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    margin: 0;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #f6aea9;
    margin-bottom: 20px;
}

.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

/* Data table - Gmail inbox style */
.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}

.data-table tbody tr:hover {
    background: rgba(60, 64, 67, 0.04);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 12px 16px;
    color: var(--text);
    vertical-align: top;
    max-width: 280px;
    word-break: break-word;
}

.data-table td.cell-muted {
    color: var(--text-secondary);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success {
    background: #e6f4ea;
    color: #137333;
}

.badge-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-neutral {
    background: #f1f3f4;
    color: var(--text-secondary);
}

@media (max-width: 900px) {
    .topbar-search {
        display: none;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 64px;
        bottom: 0;
        z-index: 90;
        transition: left 0.25s;
        box-shadow: var(--shadow);
    }

    .sidebar.open {
        left: 0;
    }

    .menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        padding: 12px;
    }

    .user-name {
        display: none;
    }
}
