/* Alexandrian Conclave Simulator Styles */

/* Skip navigation — visible only on focus for keyboard users */
.skip-nav {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 1000;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
    font-weight: bold;
    border-radius: 0 0 4px 4px;
}
.skip-nav:focus {
    top: 0;
}

:root {
    --primary: #800080;      /* Purple - Alexandrian liturgical */
    --primary-light: #9B30FF;
    --gold: #D4AF37;         /* Gold - Alexandrian liturgical */
    --gold-light: #F0D060;
    --dark: #1a1a1a;
    --gray: #555;
    --light-gray: #f5f5f5;
    --white: #fff;
    --success: #1e7e34;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #117a8b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--light-gray);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header a {
    color: var(--gold-light);
    text-decoration: none;
}

.header a:hover {
    text-decoration: underline;
}

.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-nav ul {
    display: flex;
    list-style: none;
    gap: 1.5rem;
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.container-narrow {
    max-width: 800px;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    border-bottom: 2px solid var(--gold);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.card-header h2 {
    color: var(--primary);
    font-size: 1.25rem;
}

.card-header h3 {
    color: var(--primary);
    font-size: 1.1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--dark);
}

.form-group .hint {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(128, 0, 128, 0.15);
}

input[type="number"] {
    width: 100px;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

.btn:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-secondary {
    background: var(--gray);
    color: var(--white);
}

.btn-secondary:hover {
    background: #444;
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #218838;
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Inline logout form styled as nav link */
.logout-form {
    display: inline;
}
.logout-form button {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.logout-form button:hover {
    color: var(--primary);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: var(--light-gray);
    font-weight: 600;
    color: var(--primary);
}

tr:hover {
    background: #f5f0ea;
}

.table-actions {
    white-space: nowrap;
}

.table-actions a,
.table-actions button {
    margin-right: 0.5rem;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: var(--success);
    color: var(--white);
}

.badge-warning {
    background: var(--warning);
    color: var(--dark);
}

.badge-danger {
    background: var(--danger);
    color: var(--white);
}

.badge-info {
    background: var(--info);
    color: var(--white);
}

.badge-secondary {
    background: var(--gray);
    color: var(--white);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Vote Allocation */
.candidate-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.candidate-info h4 {
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.candidate-info p {
    color: var(--gray);
    font-size: 0.9rem;
}

.candidate-platform {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
}

.ideology-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ideology-1 { background: #1a237e; color: white; }
.ideology-2 { background: #283593; color: white; }
.ideology-3 { background: #5e35b1; color: white; }
.ideology-4 { background: #ad1457; color: white; }
.ideology-5 { background: #c62828; color: white; }

.vote-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vote-input input {
    width: 80px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
}

.vote-input button {
    width: 36px;
    height: 36px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    font-size: 1.25rem;
    cursor: pointer;
}

.vote-input button:hover {
    background: var(--light-gray);
}

/* Vote Summary */
.vote-summary {
    position: sticky;
    bottom: 0;
    background: var(--white);
    padding: 1rem;
    border-top: 2px solid var(--gold);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.vote-summary .totals {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.vote-summary .count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.vote-summary .count.valid {
    color: var(--success);
}

.vote-summary .count.invalid {
    color: var(--danger);
}

/* Results */
.results-table th {
    text-align: center;
}

.results-table td {
    text-align: center;
}

.results-table td:first-child {
    text-align: left;
}

.results-table .winner {
    background: #d4edda;
}

.results-table .eliminated {
    color: var(--gray);
}

/* Progress bar */
.progress {
    height: 24px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    transition: width 0.3s;
}

.progress-bar.threshold-line {
    position: relative;
}

.progress-bar.threshold-line::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gold);
}

/* Receipt */
.receipt {
    background: #f8f9fa;
    border: 2px dashed var(--gold);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    margin: 1rem 0;
}

.receipt h3 {
    color: var(--success);
    margin-bottom: 1rem;
}

.receipt-code {
    font-family: monospace;
    font-size: 1.25rem;
    background: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    display: inline-block;
    margin: 0.5rem 0;
    word-break: break-all;
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .candidate-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .vote-input {
        margin-top: 1rem;
        width: 100%;
        justify-content: center;
    }

    .vote-input button {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .btn {
        min-height: 44px;
    }

    .header-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .header-nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card .number {
        font-size: 1.75rem;
    }

    table {
        font-size: 0.9rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th, td {
        padding: 0.5rem;
    }

    .btn {
        padding: 0.4rem 0.75rem;
    }

    .d-flex {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .number {
        font-size: 1.5rem;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .card {
        padding: 1rem;
    }

    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Login Page */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
}

.login-container .card {
    border-top: 4px solid var(--primary);
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-card .number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .label {
    color: var(--gray);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* GM Controls */
.gm-controls {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.gm-controls h4 {
    color: #856404;
    margin-bottom: 0.5rem;
}

/* Audit Log */
.audit-entry {
    padding: 0.75rem;
    border-left: 3px solid var(--gray);
    margin-bottom: 0.5rem;
    background: #f9f9f9;
}

.audit-entry.submit { border-left-color: var(--success); }
.audit-entry.edit { border-left-color: var(--warning); }
.audit-entry.gm_override { border-left-color: var(--danger); }
.audit-entry.gm_entry { border-left-color: var(--info); }

.audit-entry .timestamp {
    font-size: 0.8rem;
    color: var(--gray);
}

.audit-entry .actor {
    font-weight: 600;
}

/* === Typed Confirmation Modal === */

.confirm-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal {
    background: var(--white);
    max-width: 480px;
    width: 90%;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.confirm-modal h3 {
    color: var(--danger);
    margin-bottom: 1rem;
}

.confirm-modal .confirm-input {
    width: 100%;
    margin: 0.5rem 0;
    padding: 0.5rem;
    font-size: 1rem;
    border: 2px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.confirm-modal .confirm-input.match {
    border-color: var(--danger);
}

.confirm-modal .confirm-input.no-match {
    border-color: #ccc;
}

.confirm-modal .btn-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* === Tooltips === */

.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gray);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: bold;
    font-style: normal;
    cursor: help;
    margin-left: 0.4rem;
    vertical-align: middle;
    position: relative;
}

.tooltip-trigger:hover .tooltip-content,
.tooltip-trigger:focus .tooltip-content {
    display: block;
}

.tooltip-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.5rem;
    background: var(--dark);
    color: var(--white);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: normal;
    white-space: normal;
    width: 260px;
    z-index: 100;
    line-height: 1.4;
    text-align: left;
    pointer-events: none;
}

.tooltip-content::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--dark);
}

/* === Secret Code Masking === */

.secret-masked {
    font-family: monospace;
    letter-spacing: 0.15em;
    user-select: all;
}

.secret-toggle {
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 0.25rem;
    padding: 0.1rem 0.4rem;
}

/* === Disabled Button Distinction === */

.btn:disabled, .btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

/* === Hamburger Menu === */

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--gold-light);
    font-size: 1.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.hamburger:hover {
    color: var(--white);
}

/* === Hover & Focus Feedback === */

tr:hover td {
    background: #f5f0ea;
}

.candidate-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(128, 0, 128, 0.1);
}

.stat-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* === Shift Card Mobile Fix === */

@media (max-width: 768px) {
    .shift-card {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .shift-change {
        width: 100%;
        text-align: right;
    }
    .comparison-row {
        flex-wrap: wrap;
    }
}

/* === Mobile Hamburger Nav === */

@media (max-width: 768px) {
    .hamburger {
        display: block;
    }

    .header-nav {
        flex-wrap: wrap;
    }

    .header-nav h1 {
        flex: 1;
    }

    .header-nav nav {
        display: none;
        width: 100%;
        border-top: 1px solid rgba(255,255,255,0.2);
        padding-top: 0.5rem;
    }

    .header-nav nav.open {
        display: block;
    }

    .header-nav nav ul {
        flex-direction: column;
        gap: 0;
    }

    .header-nav nav ul li {
        padding: 0.4rem 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .header-nav nav ul li:last-child {
        border-bottom: none;
    }
}

/* === Focus-within for table rows (keyboard navigation) === */

tr:focus-within {
    background: #f5f0ea;
}

/* === Reduced motion for accessibility === */

@media (prefers-reduced-motion: reduce) {
    .btn,
    .stat-card,
    .progress-bar {
        transition: none;
    }
}
