/* ===================================
   Global Styles
   =================================== */
:root {
    --vh: 1vh;
}

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

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    overflow-x: hidden;
}

.container {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
}

/* ===================================
   Header Styles
   =================================== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

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

.data-viewer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: white;
    font-size: 1.2rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.data-viewer-link:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    height: 70px;
    width: auto;
    border-radius: 8px;
    background: white;
    padding: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.title-group h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.95;
    font-weight: 300;
}

.sync-status {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sync-status.connected {
    background: rgba(46, 213, 115, 0.3);
}

.sync-status.connected i {
    color: #2ed573;
}

.sync-status.disconnected {
    background: rgba(255, 71, 87, 0.3);
}

.sync-status.disconnected i {
    color: #ff4757;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.stat-item i {
    font-size: 1.2rem;
}

.stat-item.invasive {
    color: #ffd32a;
}

.stat-item.rare {
    color: #ffd700;
}

.stat-item strong {
    font-size: 1.1rem;
}

/* ===================================
   Main Content Layout
   =================================== */
.main-content {
    display: flex;
    flex: 1;
}

/* ===================================
   Sidebar Styles
   =================================== */
.sidebar {
    width: 320px;
    background: white;
    padding: 1.5rem;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

/* モバイル用ヘッダーはデスクトップでは非表示 */
.sidebar-header-mobile {
    display: none;
}

.sidebar-content {
    /* デスクトップでは通常表示 */
}

.sidebar-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section h3 {
    color: #667eea;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* User Settings */
.user-settings label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #555;
}

.user-settings input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.help-text {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-top: 0.5rem;
    line-height: 1.4;
}

/* Filter Groups */
.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #555;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.checkbox-group label:hover {
    background: #f8f9fa;
}

.checkbox-group input[type="checkbox"] {
    cursor: pointer;
}

.invasive-label {
    color: #ff6348;
    font-weight: 500;
}

.rare-label {
    color: #ffd700;
    font-weight: 500;
}

/* Legend */
.legend {
    font-size: 0.9rem;
}

.legend p {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.marker-circle,
.marker-triangle,
.marker-star {
    width: 20px;
    height: 20px;
    display: inline-block;
}

.marker-circle {
    border-radius: 50%;
    background: #3498db;
}

.marker-triangle {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid #ff6348;
}

.marker-star {
    background: #ffd700;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* ===================================
   Map Styles
   =================================== */
.map-wrapper {
    flex: 1;
    position: relative;
    background: #e0e0e0;
    min-height: 400px;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* ===================================
   Modal Styles
   =================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

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

.modal-header h2 {
    color: #667eea;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #95a5a6;
    cursor: pointer;
    transition: color 0.3s;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #e74c3c;
}

/* Form Styles */
form {
    padding: 1.5rem;
}

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

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

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

.form-group textarea {
    resize: vertical;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.modal-footer .btn {
    flex: 1;
}

/* ===================================
   Footer Styles
   =================================== */
.footer {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.9rem;
}

.footer strong {
    color: #ffd700;
}

.footer i {
    margin: 0 0.25rem;
}

/* ===================================
   Notification Styles
   =================================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: #2ecc71;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    display: none;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.show {
    display: block;
}

.notification.error {
    background: #e74c3c;
}

.notification.info {
    background: #3498db;
}

.notification.warning {
    background: #f39c12;
}

/* ===================================
   Leaflet Custom Styles
   =================================== */
.custom-marker {
    text-align: center;
    font-size: 24px;
    line-height: 1;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    margin: 1rem;
    min-width: 250px;
}

.popup-content h3 {
    color: #667eea;
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
}

.popup-content p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.popup-content strong {
    color: #2c3e50;
}

.popup-image {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 6px;
    margin-top: 0.5rem;
}

.popup-delete-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 0.75rem;
    width: 100%;
    font-weight: 500;
    transition: background 0.3s;
}

.popup-delete-btn:hover {
    background: #c0392b;
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }

    .logo {
        height: 60px;
    }

    .title-group h1 {
        font-size: 1.6rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 2px solid #e0e0e0;
    }

    .map-wrapper {
        height: 60vh;
    }

    .header {
        padding: 1rem;
    }

    .header-top {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .logo-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .logo {
        height: 50px;
    }

    .title-group h1 {
        font-size: 1.4rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .stats-bar {
        gap: 1rem;
        font-size: 0.85rem;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
    }

    .logo {
        height: 40px;
    }

    .title-group h1 {
        font-size: 1.2rem;
    }

    .stats-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .sidebar {
        padding: 1rem;
    }

    .sidebar-section h3 {
        font-size: 1rem;
    }

    form {
        padding: 1rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }
}
