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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 320px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.modal-content p {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

.modal-content input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 0.5rem;
    border: 2px solid;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.modal-content button {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 0.5rem;
}

.error {
    color: #e53935;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.hidden {
    display: none !important;
}

/* App container */
#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

#zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#zoom-controls button {
    width: 32px;
    height: 32px;
    border: 1px solid;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

#zoom-controls #zoom-fit {
    width: auto;
    padding: 0 0.75rem;
    font-size: 0.85rem;
}

#zoom-level {
    font-size: 0.85rem;
    min-width: 50px;
    text-align: center;
}

/* Mindmap container */
#mindmap-container {
    flex: 1;
    overflow: auto;
    position: relative;
}

#mindmap {
    display: flex;
    align-items: center;
    min-width: 100%;
    min-height: 100%;
    padding: 2rem;
    transform-origin: center center;
    transition: transform 0.3s ease;
}

/* Nodes */
.node {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.node:hover {
    transform: scale(1.05);
}

.node-icon {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    margin-bottom: 0.5rem;
}

.node-title {
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.root-node {
    margin-right: 2rem;
}

.root-node .node-title {
    font-size: 1rem;
    font-weight: 600;
}

/* Nodes container - horizontal layout */
.nodes-container {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.node-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Subnodes */
.subnodes-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 2px solid;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.subnodes-container.expanded {
    max-height: 500px;
    opacity: 1;
    margin-top: 1rem;
}

.subnode {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 8px;
    gap: 0.75rem;
    position: relative;
}

.subnode-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

.subnode-title {
    font-size: 0.85rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

.subnode-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.subnode:hover .subnode-actions {
    opacity: 1;
}

.subnode-actions button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Connection lines */
.connection-line {
    position: absolute;
    height: 2px;
    transform-origin: left center;
    pointer-events: none;
}

/* Mobile styles */
@media (max-width: 768px) {
    #mindmap {
        flex-direction: column;
        align-items: flex-start;
    }

    .root-node {
        margin-right: 0;
        margin-bottom: 1rem;
    }

    .nodes-container {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .node-group {
        width: 100%;
        align-items: flex-start;
    }

    .subnodes-container {
        margin-left: 2rem;
    }

    .subnodes-container.expanded {
        margin-top: 0.5rem;
    }

    header {
        flex-direction: column;
        gap: 0.75rem;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .node-icon {
        width: 48px;
        height: 48px;
    }

    .subnode-actions {
        opacity: 1;
    }
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
