/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    overflow: hidden;
}

/* Main container with responsive height */
#main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    position: relative;
}

/* Responsive height for full browser */
@media (min-height: 500px) {
    body:not(.iframe-mode) #main-container {
        height: 90vh;
    }
}

/* Header tooltip */
.tooltip {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    max-width: 300px;
    text-align: center;
}

#main-container:hover .tooltip {
    opacity: 1;
}

/* Control panel */
#control-panel {
    width: 280px;
    background: white;
    border-right: 2px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.tool-section {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tool-btn {
    padding: 8px 12px;
    border: none;
    background: #4CAF50;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    min-height: 36px;
    flex: 1;
    min-width: 60px;
}

.tool-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Content bank */
.content-bank {
    flex: 1;
    padding: 10px;
}

.bank-section {
    margin-bottom: 15px;
}

.bank-section h4 {
    color: #333;
    margin-bottom: 8px;
    font-size: 14px;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 4px;
}

/* Draggable items with color coding */
.draggable-item {
    padding: 8px 10px;
    margin: 4px 0;
    border-radius: 6px;
    cursor: grab;
    font-size: 12px;
    line-height: 1.3;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    user-select: none;
}

.draggable-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.draggable-item:active {
    cursor: grabbing;
    transform: scale(1.05);
}

/* Color coding for time periods */
.colonial-era {
    background: linear-gradient(135deg, #FFE5B4, #FFDAB9);
    border-color: #DEB887;
}

.war-era {
    background: linear-gradient(135deg, #FFB6C1, #FFA0B4);
    border-color: #DC143C;
}

.merger-era {
    background: linear-gradient(135deg, #E6E6FA, #D8BFD8);
    border-color: #9370DB;
}

.independence-era {
    background: linear-gradient(135deg, #98FB98, #90EE90);
    border-color: #32CD32;
}

/* Canvas area */
#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.canvas {
    width: 100%;
    height: 100%;
    position: relative;
    background: radial-gradient(circle at center, #ffffff 0%, #f8f9fa 100%);
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(76, 175, 80, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(33, 150, 243, 0.1) 0%, transparent 50%);
}

/* Central node */
.central {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3);
    z-index: 10;
}

/* Concept nodes on canvas */
.concept-node {
    position: absolute;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.3;
    cursor: move;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    z-index: 5;
    max-width: 120px;
    text-align: center;
    transition: all 0.3s ease;
}

.concept-node:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.concept-node.selected {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

/* Connection lines SVG */
.connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    stroke: #666;
    stroke-width: 2;
    fill: none;
    marker-end: url(#arrowhead);
}

.connection-line.highlighted {
    stroke: #2196F3;
    stroke-width: 3;
}

.connection-label {
    font-size: 10px;
    fill: #333;
    text-anchor: middle;
    background: white;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Legend */
#legend {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 4px 0;
    font-size: 11px;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

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

.modal-content h3 {
    margin-bottom: 15px;
    color: #333;
}

.modal-content input,
.modal-content textarea {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.modal-content input:focus,
.modal-content textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

.modal-content textarea {
    height: 80px;
    resize: vertical;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.modal-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

#save-connection {
    background: #4CAF50;
    color: white;
}

#cancel-connection {
    background: #f44336;
    color: white;
}

.modal-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Overlay styles */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.overlay-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80%;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.overlay-content h3 {
    margin-bottom: 15px;
    color: #333;
}

.overlay-content ul {
    margin: 15px 0;
    padding-left: 20px;
}

.overlay-content li {
    margin: 8px 0;
    line-height: 1.4;
}

#close-example {
    background: #2196F3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
}

#close-example:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

/* Feedback */
.feedback {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: #4CAF50;
    color: white;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feedback.error {
    background: #f44336;
}

.feedback.show {
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #control-panel {
        width: 240px;
    }
    
    .draggable-item {
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .tool-btn {
        font-size: 11px;
        padding: 6px 8px;
        min-width: 50px;
    }
    
    .concept-node {
        font-size: 10px;
        padding: 8px 10px;
        max-width: 100px;
    }
    
    .legend {
        font-size: 10px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .draggable-item,
    .concept-node,
    .tool-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .tool-btn {
        padding: 12px;
    }
}