* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    -webkit-text-size-adjust: 100%; /* Prevents text size adjustment on iOS */
    -webkit-font-smoothing: antialiased; /* Better font rendering */
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 2rem;
    font-weight: bold;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info a {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    background: rgba(255,255,255,0.2);
    border-radius: 5px;
    transition: background 0.3s;
}

.user-info a:hover {
    background: rgba(255,255,255,0.3);
}

/* Navigation */
.main-nav {
    background: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px 0;
    align-items: center;
}

/* Ensure nav menu is visible on desktop */
@media (min-width: 769px) {
    .nav-menu {
        display: flex !important;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
}

.nav-menu li a {
    display: block;
    padding: 12px 18px;
    text-decoration: none;
    color: #555;
    border-radius: 8px;
    transition: all 0.3s;
    font-weight: 500;
}

.nav-menu li a:hover {
    background: #f0f0f0;
    color: #667eea;
    transform: translateY(-2px);
}

.nav-menu li a.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Main Content */
main {
    min-height: calc(100vh - 200px);
    padding: 30px 0;
}

.content-header {
    background: white;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.content-header h2 {
    color: #667eea;
    margin-bottom: 10px;
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.card h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.card p {
    color: #666;
    margin-bottom: 10px;
}

.card-meta {
    font-size: 0.9rem;
    color: #999;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
}

.btn-danger {
    background: #dc3545;
}

/* Lists */
.info-list {
    list-style: none;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.info-list li {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-list li:last-child {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-primary {
    background: #cce5ff;
    color: #004085;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.empty-state h3 {
    color: #999;
    margin-bottom: 10px;
}

.empty-state p {
    color: #bbb;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 50px;
}

/* Event specific */
.event-type-secret {
    background: #fff3cd;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.85rem;
    color: #856404;
}

.event-type-public {
    background: #d4edda;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.85rem;
    color: #155724;
}

/* Forms */
.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-check-input {
    margin-right: 8px;
}

.form-group {
    margin-bottom: 20px;
}

select.form-control[multiple] {
    min-height: 120px;
}

textarea.form-control {
    resize: vertical;
}

/* Alert messages */
.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Dark Mode Toggle Button */
.nav-menu .dark-mode-toggle {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.dark-mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #555;
    transition: all 0.3s;
    font-family: inherit;
    white-space: nowrap;
    text-decoration: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.dark-mode-btn:hover {
    background: #f0f0f0;
    color: #667eea;
    transform: translateY(-2px);
}

.dark-mode-btn:active {
    transform: translateY(0);
}

.dark-mode-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.dark-mode-text {
    font-weight: 500;
}

/* Dark Mode Styles */
html.dark-mode,
body.dark-mode {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

body.dark-mode .main-nav {
    background: #2d2d2d;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

body.dark-mode .nav-menu li a {
    color: #d0d0d0;
}

body.dark-mode .nav-menu li a:hover {
    background: #3a3a3a;
    color: #a0a0ff;
}

body.dark-mode .nav-menu li a.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

body.dark-mode .content-header {
    background: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark-mode .content-header h2 {
    color: #a0a0ff;
}

body.dark-mode .card {
    background: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark-mode .card:hover {
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

body.dark-mode .card h3 {
    color: #a0a0ff;
}

body.dark-mode .card p {
    color: #c0c0c0;
}

body.dark-mode .card-meta {
    color: #999;
    border-top: 1px solid #404040;
}

body.dark-mode .info-list {
    background: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark-mode .info-list li {
    border-bottom: 1px solid #404040;
}

body.dark-mode .badge-success {
    background: #2d4a2d;
    color: #90ee90;
}

body.dark-mode .badge-danger {
    background: #4a2d2d;
    color: #ff6b6b;
}

body.dark-mode .badge-warning {
    background: #4a4a2d;
    color: #ffd93d;
}

body.dark-mode .badge-info {
    background: #2d3a4a;
    color: #6bc5ff;
}

body.dark-mode .badge-primary {
    background: #2d3a4a;
    color: #6bc5ff;
}

body.dark-mode .empty-state {
    background: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark-mode .empty-state h3 {
    color: #999;
}

body.dark-mode .empty-state p {
    color: #666;
}

body.dark-mode footer {
    background: #1a1a1a;
    color: #999;
}

body.dark-mode .event-type-secret {
    background: #4a4a2d;
    color: #ffd93d;
}

body.dark-mode .event-type-public {
    background: #2d4a2d;
    color: #90ee90;
}

body.dark-mode .form-control {
    background: #2d2d2d;
    border: 1px solid #404040;
    color: #e0e0e0;
}

body.dark-mode .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

body.dark-mode .alert-danger {
    background: #4a2d2d;
    color: #ff6b6b;
    border: 1px solid #5a3d3d;
}

body.dark-mode .alert-success {
    background: #2d4a2d;
    color: #90ee90;
    border: 1px solid #3d5a3d;
}

body.dark-mode .alert-info {
    background: #2d3a4a;
    color: #6bc5ff;
    border: 1px solid #3d4a5a;
}

body.dark-mode .dark-mode-btn {
    color: #d0d0d0;
}

body.dark-mode .dark-mode-btn:hover {
    background: #3a3a3a;
    color: #a0a0ff;
    transform: translateY(-2px);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #555;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 5px;
    transition: background 0.3s;
}

.mobile-menu-toggle:hover {
    background: #f0f0f0;
}

/* Responsive */
@media (max-width: 768px) {
    /* Container padding */
    .container {
        padding: 0 15px;
    }
    
    /* Header adjustments */
    header {
        padding: 1rem 0;
    }
    
    header .container {
        flex-direction: row;
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .user-info {
        flex-wrap: wrap;
        gap: 8px;
        font-size: 0.9rem;
    }
    
    .user-info a {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-height: 36px; /* Touch target */
        display: inline-flex;
        align-items: center;
        touch-action: manipulation;
    }
    
    /* Mobile Navigation */
    .mobile-menu-toggle {
        display: block;
        margin-left: auto;
    }
    
    .main-nav .container {
        position: relative;
    }
    
    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        border-radius: 0 0 10px 10px;
        padding: 10px;
        margin: 0 15px;
        z-index: 200;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-menu li {
        width: 100%;
    }
    
    .nav-menu li a {
        width: 100%;
        text-align: left;
        padding: 12px 15px;
    }
    
    .nav-menu .dark-mode-toggle {
        margin-left: 0;
        width: 100%;
    }
    
    .dark-mode-btn {
        width: 100%;
        justify-content: flex-start;
    }
    
    /* Main content */
    main {
        padding: 20px 0;
    }
    
    .content-header {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .content-header h2 {
        font-size: 1.5rem;
    }
    
    /* Cards */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .card {
        padding: 15px;
    }
    
    .card h3 {
        font-size: 1.1rem;
    }
    
    /* Buttons - touch-friendly */
    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        display: block;
        text-align: center;
        margin-top: 8px;
        min-height: 44px; /* Touch target size */
        touch-action: manipulation; /* Prevents double-tap zoom */
    }
    
    .nav-menu li a {
        min-height: 44px; /* Touch target size */
        display: flex;
        align-items: center;
        touch-action: manipulation;
    }
    
    /* Forms */
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    /* Info lists */
    .info-list {
        padding: 15px;
    }
    
    .info-list li {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px;
    }
    
    /* Footer */
    footer {
        padding: 15px 0;
        font-size: 0.85rem;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .user-info {
        font-size: 0.85rem;
    }
    
    .user-info span {
        display: block;
        width: 100%;
    }
    
    .content-header {
        padding: 15px 10px;
    }
    
    .content-header h2 {
        font-size: 1.3rem;
    }
    
    .card {
        padding: 12px;
    }
    
    .card h3 {
        font-size: 1rem;
    }
    
    .btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
}

/* Dark mode mobile adjustments */
@media (max-width: 768px) {
    body.dark-mode .mobile-menu-toggle {
        color: #d0d0d0;
    }
    
    body.dark-mode .mobile-menu-toggle:hover {
        background: #3a3a3a;
    }
    
    body.dark-mode .nav-menu {
        background: #2d2d2d;
        box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    }
}

/* Mobile optimizations for maps and complex layouts */
@media (max-width: 768px) {
    /* Map containers */
    #mapContainer,
    #locationsMap {
        height: 400px !important;
    }
    
    /* Map instructions overlay */
    #mapInstructions {
        max-width: calc(100% - 20px) !important;
        left: 10px !important;
        right: 10px !important;
        font-size: 0.85rem !important;
        padding: 8px !important;
    }
    
    /* Search and form flex containers - stack on mobile */
    div[style*="display: flex"][style*="gap"] {
        flex-wrap: wrap;
    }
    
    /* Buttons in search/filter containers */
    div[style*="display: flex"] button.btn,
    div[style*="display: flex"] a.btn {
        flex: 1 1 100%;
        min-width: 100%;
        margin-bottom: 8px;
    }
    
    /* Inputs in flex containers should be full width */
    div[style*="display: flex"] input.form-control {
        flex: 1 1 100% !important;
        min-width: 100%;
        margin-bottom: 8px;
    }
    
    /* Labels with flex - make them stack */
    label[style*="display: flex"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100% !important;
        margin-bottom: 10px;
    }
    
    label[style*="display: flex"] input,
    label[style*="display: flex"] select {
        width: 100% !important;
        margin-top: 5px;
    }
    
    /* Map type selector buttons */
    div[style*="border-bottom"] button.btn,
    div[style*="border-bottom"] a.btn {
        flex: 1 1 auto;
        min-width: calc(33.333% - 7px);
    }
}

/* Tables - make them scrollable on mobile */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    table thead,
    table tbody,
    table tr {
        display: block;
    }
    
    table thead {
        display: none;
    }
    
    table tr {
        border: 1px solid #ddd;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 5px;
    }
    
    table td {
        display: block;
        text-align: right;
        padding: 8px;
        border: none;
        border-bottom: 1px solid #eee;
    }
    
    table td:before {
        content: attr(data-label) ": ";
        float: left;
        font-weight: bold;
    }
    
    table td:last-child {
        border-bottom: none;
    }
}
