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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #ffffff;
    overflow: hidden;
    height: 100vh;
    position: relative;
}

/* Header Styles */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    color: #333;
    padding: 0.75rem 1rem;
    z-index: 1000;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
    border-bottom: 1px solid #e0e0e0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #333;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.school-selector {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    background: white;
    color: #333;
    font-size: 0.875rem;
}

.school-selector option {
    background: white;
    color: #333;
}

.menu-buttons {
    display: flex;
    gap: 0.5rem;
}

.menu-btn {
    background: #f5f5f5;
    border: 1px solid #d0d0d0;
    color: #666;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.menu-btn:hover {
    background: #e8e8e8;
    border-color: #b0b0b0;
}

/* Main Content */
.main-content {
    height: 100vh;
    position: relative;
    padding-top: 4.5rem;
    padding-bottom: 80px;
}

/* Map Styles */
.map-container {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 0;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
    filter: grayscale(70%) contrast(0.9) brightness(1.05);
}

/* Map styling for better reliability */
#map .leaflet-tile-pane {
    opacity: 0.8;
}

#map .leaflet-container {
    background-color: #f0f0f0;
}

/* Thing Cards on Map */
.thing-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    border: 2px solid #e0e0e0;
    position: relative;
    max-width: 200px;
    font-size: 12px;
    cursor: default;
    transition: all 0.3s ease;
}

.thing-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.thing-card.my-thing {
    border-color: #4CAF50;
    background: linear-gradient(to bottom, #f8fff8, #ffffff);
}

.thing-card.agreed {
    border-color: #4CAF50;
    background: linear-gradient(to bottom, #f8fff8, #ffffff);
}

.thing-dot {
    position: absolute;
    top: -6px;
    left: 12px;
    width: 12px;
    height: 12px;
    background: #666;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

.thing-card.my-thing .thing-dot {
    background: #4CAF50;
}

.thing-card.agreed .thing-dot {
    background: #4CAF50;
}

.thing-content {
    margin-top: 4px;
}

.thing-text {
    font-size: 11px;
    line-height: 1.3;
    color: #333;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.thing-actions {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.thing-actions .action-btn {
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    background: #f5f5f5;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 2px;
}

.thing-actions .action-btn:hover {
    transform: scale(1.05);
}

.thing-actions .like-btn.active {
    background: #ffe6e6;
}

.thing-actions .agree-btn.active {
    background: #e6ffe6;
}

.thing-actions .edit-btn {
    background: #fff3cd;
}

.thing-time {
    font-size: 9px;
    color: #999;
    text-align: right;
}

/* Marker styles */
.thing-card-marker {
    background: transparent !important;
    border: none !important;
}

.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
}

/* Custom Map Markers */
.thing-marker {
    background: #fff;
    border: 3px solid #667eea;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.thing-marker:hover {
    transform: scale(1.2);
    border-width: 4px;
}

.thing-marker.liked {
    border-color: #e74c3c;
    background: #e74c3c;
    animation: heartbeat 1.5s ease-in-out infinite;
}

.thing-marker.agreed {
    border-color: #27ae60;
    background: #27ae60;
}

.thing-marker.my-thing {
    border-color: #f39c12;
    background: #f39c12;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Thing Popup */
.thing-popup {
    max-width: 300px;
    padding: 1rem;
    border-radius: 12px;
    background: white;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid #e0e6ed;
}

.thing-popup.my-thing {
    border-left: 4px solid #27ae60;
    background: linear-gradient(to right, #f8fff9, #ffffff);
}

.thing-popup.agreed {
    border-left: 4px solid #27ae60;
    background: linear-gradient(to right, #f8fff9, #ffffff);
}

.thing-text {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    color: #2c3e50;
}

.thing-image {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.thing-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.thing-meta {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

/* Create Thing Panel */
.create-thing-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 2000;
    overflow: hidden;
}

.panel-header {
    background: #f8f8f8;
    color: #333;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

.panel-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.panel-content {
    padding: 1.5rem;
}

#thingText {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 2px solid #e0e6ed;
    border-radius: 12px;
    resize: vertical;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    transition: border-color 0.2s;
}

#thingText:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.panel-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

.action-btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.action-btn.primary {
    background: #007aff;
    color: white;
}

.action-btn.primary:hover {
    background: #0056cc;
}

.action-btn.secondary {
    background: white;
    color: #666;
    border: 1px solid #d0d0d0;
}

.action-btn.secondary:hover {
    background: #f5f5f5;
}

.action-btn.like-btn {
    background: #e74c3c;
    color: white;
}

.action-btn.like-btn.active {
    background: #c0392b;
}

.action-btn.agree-btn {
    background: #27ae60;
    color: white;
}

.action-btn.agree-btn.active {
    background: #229954;
}

.action-btn.edit-btn {
    background: #f39c12;
    color: white;
}

.action-btn.delete-btn {
    background: #e74c3c;
    color: white;
}

/* Image Preview */
.image-preview {
    margin-top: 1rem;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content.large {
    max-width: 700px;
}

.modal-header {
    background: #f8f8f8;
    color: #333;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    border-bottom: 1px solid #e0e6ed;
    margin-bottom: 1.5rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: #7f8c8d;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Activity Summary */
.activity-summary {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

.daily-count {
    font-size: 1.1rem;
    font-weight: 500;
}

.relationship-type {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.thing-item.agreed-thing {
    border-left: 4px solid #2196f3;
    background: linear-gradient(to right, #f3f9ff, #ffffff);
}

.date-filter {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.date-filter input {
    flex: 1;
}

/* Things List */
.things-list {
    display: grid;
    gap: 1rem;
}

.thing-item {
    background: white;
    border: 1px solid #e0e6ed;
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.2s;
}

.thing-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.thing-item.my-thing {
    border-left: 4px solid #27ae60;
    background: linear-gradient(to right, #f8fff9, #ffffff);
}

/* Ranking List */
.ranking-list {
    display: grid;
    gap: 0.75rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: white;
    border: 1px solid #e0e6ed;
    border-radius: 12px;
    gap: 1rem;
}

.ranking-number {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.ranking-number.gold {
    background: linear-gradient(135deg, #f1c40f 0%, #f39c12 100%);
}

.ranking-number.silver {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
}

.ranking-number.bronze {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
}

/* Bottom Input Bar */
.bottom-input-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e6ed;
    padding: 1rem;
    z-index: 1000;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
}

.input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    max-width: 1200px;
    margin: 0 auto;
}

#quickThingInput {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e6ed;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: border-color 0.2s;
    max-height: 100px;
}

#quickThingInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.quick-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: #f8f9fa;
    color: #495057;
}

.quick-btn.primary {
    background: #007aff;
    color: white;
}

.quick-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Form Controls */
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

.setting-actions {
    text-align: right;
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

.fade-out {
    animation: fadeOut 0.3s ease;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        padding: 0 0.5rem;
    }
    
    .header-controls {
        gap: 0.5rem;
    }
    
    .school-selector {
        display: none;
    }
    
    .menu-btn {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .create-thing-panel {
        width: 95%;
        margin: 1rem;
    }
    
    .bottom-input-bar {
        padding: 0.75rem;
    }
    
    #quickThingInput {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .input-container {
        gap: 0.5rem;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #f8f9fa;
    }
    
    .modal-content,
    .create-thing-panel,
    .thing-popup,
    .bottom-input-bar {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .form-control,
    #thingText,
    #quickThingInput {
        background: #4a5568;
        color: #f8f9fa;
        border-color: #718096;
    }
    
    .thing-item {
        background: #2d3748;
        border-color: #4a5568;
    }
}