/* HopIn Combined Stylesheet - Mobile Fixed */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ==================== CSS Variables ==================== */
:root {
    /* Fonts */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Colors */
    --primary-color: hsl(96, 30%, 22%);
    --primary-hover: #253519;
    --primary-light: rgba(76, 175, 80, 0.1);
    
    /* Backgrounds */
    --bg-gradient-start: hsl(96, 30%, 22%);
    --bg-gradient-end: #253519;
    --bg-white: #dfb88e;
    --bg-light: #f5f5f5;
    
    /* Text */
    --text-primary: #000000;
    --text-secondary: #344826;
    --text-muted: #8a5226;
    
    /* Borders */
    --border-light: #253519;
    --border-primary: #253519;
    
    /* Status */
    --error-color: #f44336;
    --error-hover: #d32f2f;
    --success-color: #4caf50;
    --info-color: #2196f3;
    
    /* Buttons */
    --btn-primary-bg: #9f6a3f;
    --btn-primary-hover: #8a5226;
    --btn-secondary-bg: #f0f0f0;
    --btn-secondary-hover: #e0e0e0;
    
    /* Shadows */
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --shadow-overlay: rgba(0, 0, 0, 0.5);
}

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

html {
    /* Prevent bounce/overscroll on mobile */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    /* Ensure full viewport height */
    height: 100%;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    /* Fix for mobile: use vh instead of min-height and add position fixed background */
    height: 100vh;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    
    /* Prevent overscroll bounce on iOS */
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
    
    /* Ensure background covers overscroll areas */
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
}

/* Alternative approach - add a fixed background element */
body::before {
    content: '';
    position: fixed;
    top: -50vh;
    left: 0;
    right: 0;
    bottom: -50vh;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    z-index: -1;
}

/* ==================== Layout ==================== */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    /* Remove min-height: 100vh and flex centering for mobile */
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* Center content only on larger screens */
@media (min-width: 769px) {
    .container {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.page {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 8px 32px var(--shadow-light);
    width: 100%;
    position: relative;
}

/* ==================== Logo ==================== */
.logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-image {
    width: 300px;
    height: auto;
    margin-bottom: 12px;
}

.logo h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.logo p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

input[type="text"],
input[type="tel"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 16px;
    font-family: var(--font-primary);
    transition: border-color 0.3s, box-shadow 0.3s;
    background: white;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--border-primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ==================== Buttons ==================== */
.btn {
    width: 100%;
    padding: 14px;
    background: var(--btn-primary-bg);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    background: var(--btn-primary-hover);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
}

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

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
}

.cancel-btn {
    background: var(--error-color);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

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

/* ==================== Event Page ==================== */
.event-info {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 32px;
    border: 2px solid var(--border-light);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.event-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.event-detail {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.event-detail strong {
    margin-right: 8px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    margin: 0;
    color: var(--text-primary);
}

/* ==================== Ride Cards ==================== */
.ride-card {
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    background: white;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ride-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-light);
}

.ride-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.driver-info {
    font-weight: 500;
    font-size: 1.1rem;
}

.seats-available {
    color: var(--success-color);
    font-weight: 500;
}

.seats-full {
    color: var(--error-color);
    font-weight: 500;
}

.car-info {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.driver-notes {
    background: var(--bg-light);
    padding: 8px;
    border-radius: 4px;
    font-style: italic;
    margin-top: 8px;
    border-left: 3px solid var(--primary-color);
}

.riders-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.riders-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.rider-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.no-drivers {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    background: var(--bg-light);
    border-radius: 8px;
    border: 2px dashed var(--border-light);
}

/* ==================== Modal Forms ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--shadow-overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin: 0 0 24px 0;
    text-align: center;
}

.form-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-buttons .btn {
    margin-bottom: 0;
}

/* ==================== Notifications ==================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 2000;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background: var(--success-color);
}

.notification-error {
    background: var(--error-color);
}

.notification-info {
    background: var(--info-color);
}

/* ==================== Loading Spinner ==================== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

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

/* ==================== Responsive Design ==================== */
@media (max-width: 768px) {
    /* Mobile-specific fixes */
    html, body {
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }
    
    body {
        /* Stronger mobile background fix */
        background-attachment: scroll;
        min-height: 100vh;
        height: auto;
    }
    
    .container {
        padding: 10px;
        min-height: calc(100vh - 20px);
        /* Remove flex centering on mobile */
        display: block;
    }
    
    .page {
        padding: 20px;
        margin: 10px 0;
    }
    
    .event-header,
    .section-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .event-header .btn,
    .section-header .btn {
        width: 100%;
    }
    
    .logo-image {
        width: 200px;
    }
    
    /* Fix notification positioning on mobile */
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
        width: auto;
    }
    
    .notification.show {
        transform: translateY(0);
    }
}

/* ==================== iOS Safari specific fixes ==================== */
@supports (-webkit-appearance: none) {
    body {
        /* Additional iOS Safari fix */
        position: relative;
        overflow-x: hidden;
    }
    
    .container {
        position: relative;
        overflow: visible;
    }
}

/* ==================== Print Styles ==================== */
@media print {
    .btn, .cancel-btn {
        display: none;
    }
    
    body {
        background: white;
    }
    
    .page {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ==================== Waitlist Section ==================== */
.waitlist-section {
    margin-top: 32px;
}

.waitlist-list {
    margin-top: 16px;
}

.waitlist-entry {
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.waitlist-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-light);
}

.waitlist-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.waitlist-position {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    width: fit-content;
}

.waitlist-name {
    font-weight: 500;
    font-size: 1rem;
    color: var(--text-primary);
}

.waitlist-notes {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    background: var(--bg-light);
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 4px;
}

/* ==================== Responsive Waitlist ==================== */
@media (max-width: 768px) {
    .waitlist-entry {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .waitlist-entry .cancel-btn {
        width: 100%;
    }
}

/* ==================== Chat System ==================== */
.chat-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-light);
    flex-wrap: wrap;
}

.chat-tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s;
    font-size: 14px;
}

.chat-tab:hover {
    color: var(--primary-color);
}

.chat-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.chat-container {
    border: 2px solid var(--border-light);
    border-radius: 8px;
    background: white;
    display: flex;
    flex-direction: column;
    height: 400px;
    max-height: 60vh;
}

.chat-header {
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageSlideIn 0.2s ease-out;
}

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

.chat-message.own-message {
    align-self: flex-end;
}

.chat-message.other-message {
    align-self: flex-start;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.own-message .message-sender {
    text-align: right;
    color: var(--primary-color);
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.4;
}

.own-message .message-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.other-message .message-bubble {
    background: var(--bg-light);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.own-message .message-time {
    text-align: right;
}

.chat-input-container {
    padding: 12px 16px;
    border-top: 2px solid var(--border-light);
    display: flex;
    gap: 8px;
    background: var(--bg-light);
    border-radius: 0 0 6px 6px;
}

.chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border-light);
    border-radius: 20px;
    font-size: 14px;
    font-family: var(--font-primary);
    resize: none;
    max-height: 100px;
    min-height: 40px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-send-btn {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
    white-space: nowrap;
}

.chat-send-btn:hover {
    background: var(--primary-hover);
}

.chat-send-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.chat-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.chat-section {
    margin-top: 32px;
}

.chat-button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-toggle-btn {
    flex: 1;
    min-width: 150px;
    padding: 12px;
    background: var(--info-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chat-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-medium);
}

.chat-toggle-btn.event-chat {
    background: var(--primary-color);
}

.chat-toggle-btn.event-chat:hover {
    background: var(--primary-hover);
}

.chat-toggle-btn.driver-chat {
    background: var(--btn-primary-bg);
}

.chat-toggle-btn.driver-chat:hover {
    background: var(--btn-primary-hover);
}

.car-chat-btn {
    padding: 8px 16px;
    background: var(--info-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    white-space: nowrap;
}

.car-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--shadow-medium);
}

.notification-badge {
    background: var(--error-color);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* ==================== Responsive Chat ==================== */
@media (max-width: 768px) {
    .chat-container {
        height: 350px;
        max-height: 50vh;
    }
    
    .chat-message {
        max-width: 90%;
    }
    
    .chat-button-group {
        flex-direction: column;
    }
    
    .chat-toggle-btn {
        width: 100%;
        min-width: auto;
    }
    
    .chat-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .chat-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
}