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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f0f2f5;
    color: #1a1a1a;
    overflow: hidden; /* Prevent body scroll */
}

.container {
    max-width: 100vw;
    height: 100vh;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 16px;
}

header h1 {
    font-size: 1.75rem;
    color: #1e293b;
    font-weight: 800;
}

.subtitle {
    color: #64748b;
    font-size: 0.9rem;
}

.main-content {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0; /* Important for flex child with overflow */
}

/* Sidebar */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding-right: 4px;
}

.control-panel, .info-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.control-panel h2, .info-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: #1e293b;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.control-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.control-group h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: #475569;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group h4 {
    font-size: 0.8rem;
    margin-top: 12px;
    margin-bottom: 8px;
    color: #64748b;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: 8px;
}

.btn {
    padding: 8px 12px;
    background-color: #f8fafc;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
    border: none;
    width: 100%;
}

.btn-primary:hover {
    background-color: #2563eb;
}

.btn-danger {
    color: #ef4444;
}

.btn-danger:hover {
    background-color: #fef2f2;
    border-color: #fecaca;
}

.btn-palette {
    background-color: #94a3b8;
    color: white;
    width: 100%;
    margin-top: 8px;
}

.control-hint {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#colorPicker {
    width: 100%;
    height: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

.preset-colors-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    margin-top: 8px;
    max-height: 120px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #f1f5f9;
    border-radius: 6px;
}

.preset-color-item {
    aspect-ratio: 1;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s;
}

.preset-color-item:hover {
    transform: scale(1.15);
    z-index: 10;
}

/* Map Container */
.map-container {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    border: 1px solid #e2e8f0;
    min-width: 0;
}

.map-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f8fafc;
    outline: 2px solid transparent;
    transition: outline-color 0.3s;
}

.map-wrapper.at-boundary {
    outline-color: rgba(239, 68, 68, 0.3);
}

.map-wrapper svg {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

.map-wrapper svg:active {
    cursor: grabbing;
}

/* SVG Elements */
.map-wrapper svg path {
    transition: fill 0.2s, stroke-width 0.2s, stroke 0.2s;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.map-wrapper svg g[id="Länder"] path {
    fill: #e2e8f0;
    stroke: #475569;
    stroke-width: 0.5px;
    cursor: pointer;
}

.map-wrapper svg g[id="Länder"] path.no-border {
    stroke: none !important;
}

.map-wrapper svg g[id="Länder"] path:hover,
.map-wrapper svg g[id="Länder"] path.hovered {
    fill: #cbd5e1;
    stroke-width: 1px;
}

.map-wrapper svg g[id="Länder"] path.selected {
    stroke: #3b82f6 !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.5));
}

/* Legend */
.legend {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.02); /* Extremely transparent as requested */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    min-width: 200px;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    transition: all 0.3s;
}

.legend:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    cursor: move;
}

.legend-title-input {
    flex: 1;
    border: none;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
    background: transparent;
    padding: 4px;
    border-radius: 4px;
}

.legend-close {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    font-size: 1rem;
    color: #64748b;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.legend-color-input {
    width: 24px;
    height: 20px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 3px;
    cursor: pointer;
}

.legend-label-input {
    flex: 1;
    font-size: 0.8rem;
    color: #334155;
    border: 1px solid transparent;
    background: transparent;
    padding: 2px 4px;
}

.legend-label-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: rgba(255, 255, 255, 0.5);
}

.legend-delete-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1rem;
}

.legend-delete-btn:hover {
    color: #ef4444;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background-color: rgba(15, 23, 42, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 1100;
    display: none;
    white-space: nowrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tooltip.show {
    display: block;
}

/* Hints */
.map-controls-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    padding: 6px 12px;
    border-radius: 16px;
    display: flex;
    gap: 16px;
    font-size: 0.7rem;
    color: #64748b;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.map-wrapper:hover .map-controls-hint {
    opacity: 1;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

.picked-color-preview {
    margin-top: 16px;
    padding: 16px;
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
    text-align: center;
}

.picked-color-preview .color-box {
    width: 80px;
    height: 48px;
    margin: 0 auto 8px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

.picked-color-preview .color-value {
    font-family: monospace;
    font-size: 0.9rem;
}

/* Selection classes */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.toggle-label input {
    width: 16px;
    height: 16px;
}
