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

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

/* Header styles */
.header {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.header nav {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Container styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Form styles */
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 500px;
    margin: 2rem auto;
}

.file-input {
    padding: 0.5rem;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Button styles */
.btn {
    background-color: #3498db;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    background-color: #2980b9;
}

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

.btn-secondary:hover {
    background-color: #6d7677;
}

/* Mindmap container */
.mindmap-container {
    width: 100%;
    min-height: 400px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    position: relative;
    z-index: 10;
}

/* Node styles */
.node {
    display: inline-block;
    padding: 10px 20px;
    margin: 10px;
    background-color: #e6f3fa;
    border: 1px solid #3498db;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    font-size: 1.1rem;
    max-width: 300px;
    word-wrap: break-word;
}

.node.expanded::before {
    content: '−';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: #3498db;
}

.node:not(.expanded)::before {
    content: '+';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: #3498db;
}

.children-container {
    display: none;
    margin-left: 40px;
}

.node.expanded > .children-container {
    display: block;
}

/* Popup styles */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-width: 90%;
    max-height: 80vh;
    overflow: auto;
}

.popup a {
    color: #3498db;
    text-decoration: none;
}

.popup a:hover {
    text-decoration: underline;
}

.popup iframe {
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
}

.popup .close-btn {
    background-color: #7f8c8d;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}

.popup .close-btn:hover {
    background-color: #6d7677;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

/* Progress bar styles */
.progress-container {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    background: #f0f0f0;
    border-radius: 8px;
    overflow: hidden;
    z-index: 1001;
    display: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    padding: 5px;
}

.progress-bar {
    height: 24px;
    background: linear-gradient(90deg, #3498db, #2980b9);
    width: 0%;
    transition: width 0.4s ease;
}

.progress-text {
    text-align: center;
    padding: 8px;
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* Fallback error styles */
#fallback-error {
    font-size: 1.2rem;
    font-weight: bold;
}

/* Table styles for list.php */
.mindmap-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
}

.mindmap-table th,
.mindmap-table td {
    padding: 0.75rem;
    border: 1px solid #ddd;
    text-align: left;
}

.mindmap-table th {
    background-color: #2c3e50;
    color: white;
}

.mindmap-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.mindmap-table tr:hover {
    background-color: #f1f1f1;
}

.mindmap-table .btn {
    padding: 0.5rem 1rem;
}

/* Responsive design */
@media (max-width: 1024px) {
    .header h1 {
        font-size: 2rem;
    }

    .header p {
        font-size: 1rem;
    }

    .mindmap-container {
        height: 70vh;
    }

    .mindmap-table th,
    .mindmap-table td {
        padding: 0.5rem;
    }

    .progress-container {
        width: 70%;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .header nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .container {
        padding: 0 1rem;
    }

    .upload-form {
        max-width: 100%;
    }

    .mindmap-container {
        height: 60vh;
        min-height: 300px;
    }

    .mindmap-table {
        font-size: 0.9rem;
    }

    .popup {
        max-width: 95%;
        padding: 15px;
    }

    .progress-container {
        width: 80%;
    }
}

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

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .mindmap-container {
        height: 50vh;
        min-height: 250px;
    }

    .mindmap-table th,
    .mindmap-table td {
        padding: 0.4rem;
        font-size: 0.8rem;
    }

    .mindmap-table .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .progress-container {
        width: 90%;
        padding: 3px;
    }

    .progress-text {
        font-size: 14px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .btn, .progress-bar {
        transition: none;
    }
}

@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    .header {
        background-color: #34495e;
    }

    .mindmap-container {
        background-color: #2c2c2c;
        border-color: #444;
    }

    .node {
        background-color: #34495e;
        border-color: #66b3ff;
        color: #e0e0e0;
    }

    .file-input {
        border-color: #666;
        background-color: #333;
        color: #e0e0e0;
    }

    .mindmap-table {
        border-color: #444;
    }

    .mindmap-table th {
        background-color: #34495e;
    }

    .mindmap-table tr:nth-child(even) {
        background-color: #2a2a2a;
    }

    .mindmap-table tr:hover {
        background-color: #333;
    }

    .popup {
        background-color: #2c2c2c;
        border-color: #444;
        color: #e0e0e0;
    }

    .popup a {
        color: #66b3ff;
    }

    .progress-container {
        background: #444;
    }

    .progress-text {
        color: #e0e0e0;
    }

    #fallback-error {
        color: #ff6666;
    }
}
