/* Boulder 2.0 - WhatsApp Dark Theme Styles */
/* Single Page Layout with Dates */

/* CSS Variables - WhatsApp Dark Theme */
:root {
    --bg-primary: #111b21;
    --bg-secondary: #202c33;
    --bg-tertiary: #2a3942;
    --accent-green: #00a884;
    --accent-green-hover: #00c49a;
    --accent-blue: #53bdeb;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --border-color: #2a3942;
    --danger: #ea4335;
    --danger-hover: #ff5a4a;
    --progress-bg: #374248;
    --progress-fill: #00a884;
    --toast-bg: #323739;
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    line-height: 1.4;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* ===== NAME SECTION (Top of page) ===== */
.name-section {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.name-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

.select-wrapper {
    width: 100%;
}

select {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238696a0' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.2);
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 10px;
}

/* ===== CURRENT USER DISPLAY ===== */
.current-user-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.current-user-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.current-user-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.current-user-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-green);
}

.btn-change-user {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-change-user:hover,
.btn-change-user:active {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--accent-green);
}

/* ===== FAVORITES SUMMARY ===== */
.favorites-summary {
    background: linear-gradient(135deg, rgba(0, 168, 132, 0.15), rgba(0, 168, 132, 0.05));
    border: 1px solid rgba(0, 168, 132, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.favorites-header {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.favorite-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 140px;
}

.favorite-icon {
    font-size: 16px;
}

.favorite-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.favorite-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-green);
}

.leading-voters {
    width: 100%;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 168, 132, 0.2);
    font-size: 13px;
    color: var(--text-secondary);
}

.leading-voters strong {
    color: var(--accent-green);
}

.btn-share {
    margin-top: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    background: var(--accent-green);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.btn-share:hover,
.btn-share:active {
    background: var(--accent-green-hover);
}

/* ===== MEETING TIME INLINE ===== */
.meeting-time-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
}

.time-icon {
    font-size: 16px;
}

.time-text {
    font-weight: 600;
    color: var(--accent-green);
}

/* Buttons */
.btn-primary {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-green-hover);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #3a4a54;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-add {
    background: transparent;
    color: var(--accent-green);
    border: 2px dashed var(--accent-green);
    padding: 12px;
    width: 100%;
    font-size: 14px;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 12px;
    transition: background 0.2s, border-color 0.2s;
}

.btn-add:hover {
    background: rgba(0, 168, 132, 0.1);
    border-color: var(--accent-green-hover);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 16px;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

/* ===== HEADER ===== */
.app-header {
    background: var(--bg-secondary);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    font-size: 24px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
}

.week-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.week-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.week-nav-btn:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.week-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.week-badge {
    background: var(--accent-green);
    color: white;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    min-width: 70px;
    text-align: center;
}

.week-badge.viewing-past {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.time-separator {
    color: var(--text-secondary);
    margin: 0 6px;
}

.voting-deadline {
    font-size: 13px;
    color: #ff6b6b;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    transition: color 0.3s, transform 0.1s;
}

.voting-deadline.voting-closed {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    font-style: italic;
}

/* Countdown animations */
.voting-deadline.plenty-time {
    color: #00a884;
}

.voting-deadline.getting-close {
    color: #f4c430;
}

.voting-deadline.hurry-up {
    color: #ff9500;
    animation: pulse 1s ease-in-out infinite;
}

.voting-deadline.last-chance {
    color: #ff3b30;
    animation: pulse 0.5s ease-in-out infinite;
}

.voting-deadline.final-countdown {
    color: #ff3b30;
    animation: shake 0.3s ease-in-out infinite, pulse 0.3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0) scale(1.1); }
    25% { transform: translateX(-3px) scale(1.1); }
    75% { transform: translateX(3px) scale(1.1); }
}

/* ===== MAIN CONTENT ===== */
.vote-content,
.stats-content,
.settings-content {
    flex: 1;
    padding: 16px;
    padding-bottom: 85px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== POLL SECTIONS ===== */
.poll-section {
    margin-bottom: 24px;
}

.poll-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.poll-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin: -8px 0 10px 0;
    opacity: 0.7;
}

.poll-options {
    background: var(--bg-secondary);
    border-radius: 14px;
    overflow: hidden;
}

/* Poll Option */
.poll-option {
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.poll-option:last-child {
    border-bottom: none;
}

.poll-option:hover {
    background: var(--bg-tertiary);
}

.poll-option.selected {
    background: rgba(0, 168, 132, 0.12);
}

.poll-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.poll-option.read-only {
    opacity: 0.7;
    cursor: default;
}

.poll-option.read-only .poll-checkbox {
    display: none;
}

.poll-option-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.poll-checkbox {
    font-size: 18px;
    color: var(--text-secondary);
    transition: color 0.15s;
}

.poll-option.selected .poll-checkbox {
    color: var(--accent-green);
}

.poll-label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.poll-date {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.poll-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 18px;
    text-align: right;
}

/* Progress Bar */
.poll-progress {
    height: 5px;
    background: var(--progress-bg);
    border-radius: 2.5px;
    overflow: hidden;
    margin-bottom: 6px;
}

.poll-progress-bar {
    height: 100%;
    background: var(--progress-fill);
    border-radius: 2.5px;
    transition: width 0.3s ease;
}

/* Voters */
.poll-voters {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    min-height: 17px;
}

/* ===== VOTE SUMMARY ===== */
.vote-summary {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 14px;
    margin-top: 20px;
    border-left: 4px solid var(--accent-green);
}

.summary-label {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.vote-summary .btn-secondary {
    margin-top: 12px;
    width: 100%;
}

/* ===== VOTING RULES ===== */
.voting-rules {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: left;
}

.voting-rules p {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.8;
}

/* ===== STATS SCREEN ===== */
.stats-description {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
}

.stats-description p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

.stats-section {
    margin-bottom: 24px;
}

.stats-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.stats-list {
    background: var(--bg-secondary);
    border-radius: 14px;
    overflow: hidden;
}

.stats-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.stats-item:last-child {
    border-bottom: none;
}

.stats-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.stats-rank {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 22px;
}

.stats-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.stats-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-green);
}

.stats-bar {
    height: 4px;
    background: var(--progress-bg);
    border-radius: 2px;
    overflow: hidden;
}

.stats-bar-fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ===== SETTINGS SCREEN ===== */
.settings-section {
    margin-bottom: 28px;
}

.settings-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.settings-list {
    background: var(--bg-secondary);
    border-radius: 14px;
    overflow: hidden;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item-name {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-item-actions {
    display: flex;
    gap: 2px;
    margin-left: 8px;
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color);
    z-index: 50;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 20px;
    cursor: pointer;
    transition: color 0.2s, transform 0.1s;
    min-width: 70px;
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item.active {
    color: var(--accent-green);
}

.nav-icon {
    font-size: 20px;
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toast-bg);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    z-index: 150;
    animation: toastIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: calc(100% - 40px);
    text-align: center;
}

.toast.hidden {
    display: none;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 16px;
    width: 100%;
    max-width: 340px;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 14px;
}

.modal-message {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent-green);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 27, 33, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== RESPONSIVE ===== */
@media (min-width: 480px) {
    .vote-content,
    .stats-content,
    .settings-content {
        padding: 20px;
        padding-bottom: 95px;
        max-width: 500px;
        margin: 0 auto;
    }

    .favorites-summary {
        flex-wrap: nowrap;
    }
}

@media (max-width: 359px) {
    .poll-label {
        font-size: 13px;
    }

    .poll-date {
        font-size: 11px;
    }

    .favorite-item {
        min-width: 120px;
    }
}

/* Safe area for iOS */
@supports (padding: max(0px)) {
    .vote-content,
    .stats-content,
    .settings-content {
        padding-bottom: max(85px, calc(65px + env(safe-area-inset-bottom)));
    }
}

/* Scrollbar styling for webkit browsers */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 2.5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
