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

body {
    font-family: 'Noto Sans JP', 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: 680px;
    flex: 1 1 560px;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    text-align: left;
}

.header-tagline {
    font-size: 0.95rem;
    text-align: left;
    opacity: 0.9;
}

.header-links {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
    align-items: center;
}

.header-links a {
    display: inline-flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: underline;
}

.header-links a:hover,
.header-links a:focus {
    color: #fff;
    text-decoration: none;
}

.header-controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.projection-selector,
.language-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.projection-selector label,
.language-selector label {
    font-weight: 500;
}

.projection-selector select,
.language-selector select {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    background: white;
    color: #333;
    font-size: 1rem;
    cursor: pointer;
}

/* Main Container */
.main-container {
    display: flex;
    min-height: calc(100vh - 120px);
    gap: 1rem;
    padding: 1rem;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.sidebar .accordion-section {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.accordion-toggle {
    width: 100%;
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    text-align: left;
    gap: 0.5rem;
}

.accordion-toggle:hover,
.accordion-toggle:focus {
    color: #302f74;
    outline: none;
}

.accordion-icon {
    display: inline-flex;
    width: 1rem;
    height: 1rem;
    position: relative;
}

.accordion-icon::before,
.accordion-icon::after {
    content: '';
    position: absolute;
    background: currentColor;
    transition: transform 0.2s ease;
}

.accordion-icon::before {
    width: 100%;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.accordion-icon::after {
    width: 2px;
    height: 100%;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.accordion-section.is-open .accordion-icon::after {
    transform: translateX(-50%) scaleY(0);
}

.accordion-content {
    display: none;
    margin-top: 1rem;
}

.accordion-section.is-open .accordion-content {
    display: block;
}

.data-info-placeholder {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

.data-details {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.data-details p {
    margin: 0.3rem 0;
}

/* Input Section */
.input-type-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-type-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.input-type-selector input[type="radio"] {
    margin: 0;
}

.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover {
    border-color: #667eea;
    background-color: #f8f9ff;
}

.drop-zone.dragover {
    border-color: #667eea;
    background-color: #f0f2ff;
    transform: scale(1.02);
}

.file-input-button {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.file-input-button:hover {
    background: #5a67d8;
}

#file-input {
    display: none;
}

.file-info {
    background: #e6f3ff;
    padding: 1rem;
    border-radius: 5px;
    margin-top: 1rem;
}

.file-info p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

/* Webcam Section */
.webcam-area {
    margin-top: 1rem;
}

.webcam-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.webcam-notice {
    font-size: 0.85rem;
    color: #555;
    margin: 0;
}

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

.camera-select-group label {
    font-weight: 500;
    font-size: 0.9rem;
}

#camera-select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.webcam-btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.webcam-btn.primary {
    background: #667eea;
    color: white;
}

.webcam-btn.primary:hover {
    background: #5a67d8;
}

.webcam-btn.secondary {
    background: #e74c3c;
    color: white;
}

.webcam-btn.secondary:hover {
    background: #c0392b;
}

.webcam-btn.success {
    background: #27ae60;
    color: white;
}

.webcam-btn.success:hover {
    background: #229954;
}

.webcam-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.webcam-preview {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#webcam-video {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 10px;
    border: 2px solid #ddd;
    background: #000;
    transform: scaleX(-1);
}

.webcam-actions {
    display: flex;
    gap: 0.5rem;
}

.webcam-actions button {
    flex: 1;
}

.webcam-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 5px;
    font-size: 0.9rem;
}

.webcam-message.info {
    background: #e6f3ff;
    color: #2c5aa0;
}

.webcam-message.error {
    background: #ffe6e6;
    color: #c0392b;
}

.webcam-message.warning {
    background: #fff9e6;
    color: #d68910;
}

/* Control Section */
.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 0.5rem;
}

.control-group span {
    font-size: 0.9rem;
    color: #666;
}

/* Info Section */
#projection-info {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Sample Section */
.sample-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.sample-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #555;
}

.sample-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.sample-btn {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    color: #555;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.sample-btn:hover {
    background: #f0f2ff;
    border-color: #667eea;
    color: #667eea;
}

.sample-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.sample-list h4 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: #666;
}

.sample-item {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sample-item:hover {
    background: #e6f3ff;
    border-color: #4a90e2;
    transform: translateY(-1px);
}

.sample-item.selected {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.sample-item.selected .sample-item-name {
    color: white;
}

.sample-item.selected .sample-item-description {
    color: rgba(255, 255, 255, 0.9);
}

.sample-item-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: #333;
    margin-bottom: 0.25rem;
}

.sample-item-description {
    font-size: 0.75rem;
    color: #666;
    line-height: 1.3;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 600px;
    min-height: 600px;
}

.canvas-wrapper svg,
.canvas-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px solid #ddd;
    border-radius: 5px;
}

#map-svg {
    background: white;
}

#webgl-canvas {
    background: #f8f9fa;
}

#image-canvas {
    background: transparent;
    pointer-events: none;
}

/* Loading */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: #eee;
    border-radius: 2px;
    margin-top: 1rem;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

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

.footer a {
    color: #ffdd57;
    text-decoration: underline;
}

.footer a:hover,
.footer a:focus {
    text-decoration: none;
}

/* SVG Styles */
.country {
    fill: none;
    stroke: #2c5aa0;
    stroke-width: 1.5px;
    transition: stroke 0.3s ease;
}

.country:hover {
    stroke: #ff6b6b;
}

.graticule,
.graticule-line {
    fill: none;
    stroke: #fff;
    stroke-width: 1px;
    stroke-opacity: 0.7;
    pointer-events: none;
}

.graticule-outline {
    fill: none;
    stroke: #fff;
    stroke-width: 2px;
    stroke-opacity: 0.8;
    pointer-events: none;
}

.sphere {
    fill: #e6f3ff;
    stroke: #4a90e2;
    stroke-width: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        order: 2;
    }

    .canvas-container {
        order: 1;
    }
    
    .canvas-wrapper {
        height: 400px;
        min-height: 400px;
    }
    
    #map-svg,
    #image-canvas,
    #webgl-canvas {
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
        text-align: center;
    }
    
    .header-text {
        align-items: center;
        text-align: center;
        gap: 0.5rem;
        max-width: 100%;
        flex: none;
    }
    
    .header h1 {
        font-size: 1rem;
        text-align: center;
    }
    
    .header-tagline {
        font-size: 0.85rem;
        text-align: center;
    }
    
    .header-links {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 0.5rem;
    }
    
    .sidebar {
        padding: 1rem;
    }
    
    .canvas-container {
        padding: 1rem;
    }
}
