/* Hills Uniforms Mailout Tool - Modern theme with auto dark mode */
:root {
    --hills-blue: #0066cc;
    --hills-green: #a3d039;
    --hills-grey: #6b7280;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --input-bg: #ffffff;
    --error: #dc2626;
    --success: #16a34a;
}

.dark, .html.dark {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --input-bg: #1e293b;
    --error: #f87171;
    --success: #4ade80;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
}

.login-card .brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Theme switch: neumorphic-style pill below sign in (login) or in header (dashboard) */
.theme-switch-wrap {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.theme-switch {
    display: inline-flex;
    padding: 4px;
    border-radius: 999px;
    background: var(--bg);
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.08), inset -2px -2px 4px rgba(255, 255, 255, 0.05);
    gap: 2px;
}

.dark .theme-switch {
    box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.3), inset -2px -2px 4px rgba(255, 255, 255, 0.03);
}

.theme-switch-option {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.25s ease;
}

.theme-switch-option:hover {
    color: var(--text);
}

.theme-switch-option.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1), -1px -1px 3px rgba(255, 255, 255, 0.4);
}

.dark .theme-switch-option.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.4), -1px -1px 4px rgba(255, 255, 255, 0.05);
}

.theme-switch-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
}

.theme-switch-icon svg {
    width: 18px;
    height: 18px;
}

.theme-switch-header {
    padding: 3px;
}

.login-card .logo {
    max-width: 220px;
    height: auto;
    margin-bottom: 0.5rem;
}

.login-card h1 {
    font-size: 1.25rem;
    color: var(--hills-blue);
    margin: 0;
}

.login-card label {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: var(--text);
}

.login-card input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
}

.login-card input:focus {
    outline: none;
    border-color: var(--hills-blue);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

.login-card .btn {
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.75rem;
    font-size: 1rem;
}

/* Dashboard */
.dashboard .main-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.main-header .logo {
    height: 36px;
    width: auto;
}

.main-header h1 {
    font-size: 1.25rem;
    color: var(--hills-blue);
    margin: 0;
    flex: 1;
}

/* Dark mode: header text uses light colour for contrast (no blue on blue) */
.dark .main-header h1 {
    color: var(--text);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.main-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

.card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.card h2 {
    font-size: 1.1rem;
    margin: 0 0 0.5rem 0;
    color: var(--text);
}

.hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 1rem 0;
}

.hint .link-download {
    color: var(--hills-blue);
    font-weight: 500;
    text-decoration: underline;
}

.hint .link-download:hover {
    text-decoration: none;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone.dragover {
    border-color: var(--hills-blue);
    background: rgba(0, 102, 204, 0.05);
}

.upload-zone p {
    margin: 0;
}

.recipients-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.recipients-summary.hidden {
    display: none;
}

.input-full {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
}

.input-full:focus {
    outline: none;
    border-color: var(--hills-blue);
}

.editor-wrap {
    position: relative;
}

#message-body {
    width: 100%;
    min-height: 280px;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
}

/* TinyMCE: match theme border and dark mode */
.editor-wrap .tox-tinymce {
    border-radius: 8px;
    border-color: var(--border) !important;
}

.dark .editor-wrap .tox-tinymce {
    border-color: var(--border) !important;
}

/* Dark mode: keep editor white like light mode for consistent editing */
.dark .editor-wrap .tox .tox-toolbar,
.dark .editor-wrap .tox .tox-toolbar-overlord,
.dark .editor-wrap .tox .tox-edit-area {
    background: #fff !important;
}

.dark .editor-wrap .tox .tox-edit-area__iframe {
    background: #fff !important;
}

.dark .editor-wrap .tox .tox-toolbar .tox-toolbar__group,
.dark .editor-wrap .tox .tox-toolbar__primary {
    background: #fff !important;
}

.dark .editor-wrap .tox .tox-toolbar button,
.dark .editor-wrap .tox .tox-toolbar .tox-tbtn {
    color: #1e293b !important;
}

.dark .editor-wrap .tox .tox-statusbar {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

/* Attachments */
.attachment-zone {
    margin-bottom: 0.75rem;
}

.attachment-progress {
    margin-top: 0.75rem;
}

.attachment-progress.hidden {
    display: none !important;
}

.attachment-progress-label {
    margin: 0 0 0.35rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.attachment-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.attachment-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--hills-blue);
    border-radius: 999px;
    transition: width 0.15s ease;
}

/* Send loading state */
.send-status.sending {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 102, 204, 0.1);
    color: var(--hills-blue);
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border);
    border-top-color: var(--hills-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.attachment-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.attachment-list li:last-child {
    border-bottom: none;
}

.att-filename {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text);
}

.send-actions {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.test-send label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.test-send .input-full {
    margin-bottom: 0.5rem;
}

.send-status {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.send-status.hidden {
    display: none;
}

.send-status.success {
    background: rgba(22, 163, 74, 0.15);
    color: var(--success);
}

.send-status.error {
    background: rgba(220, 38, 38, 0.15);
    color: var(--error);
}

.actions-card .btn {
    margin-right: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.btn-primary {
    background: var(--hills-blue);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--hills-green);
    color: #0f172a;
}

.btn-secondary:hover:not(:disabled) {
    filter: brightness(1.05);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--border);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(220, 38, 38, 0.15);
    color: var(--error);
}

.alert-info {
    background: rgba(0, 102, 204, 0.12);
    color: var(--hills-blue);
}

.alert-warning {
    background: rgba(176, 104, 0, 0.12);
    color: #a06800;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}

.dark .alert-warning {
    background: rgba(255, 176, 64, 0.12);
    color: #f0c070;
}

.resume-banner-text { flex: 1 1 320px; }
.resume-banner-detail { margin: 0.25rem 0 0 0; font-size: 0.9rem; opacity: 0.85; }
.resume-banner-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.alert-info code, .alert-info pre {
    background: var(--surface);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.dark .alert-info strong,
.dark .alert-info code,
.dark .alert-info pre {
    color: var(--text);
}

.alert-info pre {
    padding: 0.5rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.setup-hash {
    max-width: 960px;
    margin: 1rem auto 0;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.hidden {
    display: none !important;
}

/* Auto dark mode: respect system preference on first load (handled in JS) */
@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        /* JS sets .dark; this is fallback if no cookie */
    }
}
