/* 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;
    background-color: #f5f5f5;
    color: #333;
    overflow: hidden;
}

/* App container */
.app-container {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-rows: 60px 1fr;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    transition: grid-template-columns 0.3s ease;
}

/* Header */
.header {
    grid-area: header;
    background: #2c3e50;
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    margin-right: 15px;
}

.menu-toggle span {
    width: 25px;
    height: 3px;
    background: white;
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 2px;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    flex: 1;
}

.zoom-controls {
    display: flex;
    gap: 5px;
}

.zoom-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
}

.zoom-btn:active {
    transform: scale(0.95);
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    z-index: 999;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 15px;
}

.load-file-btn {
    width: 100%;
    padding: 10px 15px;
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.load-file-btn:hover {
    background: #34495e;
}

.load-file-btn:active {
    transform: translateY(1px);
}

.file-list {
    padding: 10px 0;
    flex: 1;
    overflow-y: auto;
}

.file-item {
    display: block;
    padding: 12px 20px;
    color: #555;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.file-item:hover {
    background: #f8f9fa;
    color: #2c3e50;
}

.file-item.active {
    background: #e3f2fd;
    color: #1976d2;
    border-left-color: #1976d2;
    font-weight: 500;
}

.loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Sidebar disclaimer */
.sidebar-disclaimer {
    margin-top: auto;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    font-size: 12px;
    line-height: 1.4;
}

.disclaimer-text {
    color: #e67e22;
    font-weight: 500;
    margin-bottom: 8px;
}

.contact-info {
    color: #666;
    margin: 0;
}

.contact-info a {
    color: #2c3e50;
    text-decoration: none;
    font-weight: 500;
}

.contact-info a:hover {
    color: #1976d2;
    text-decoration: underline;
}

/* Main content */
.main-content {
    grid-area: main;
    position: relative;
    overflow: hidden;
    background: white;
}

.diagram-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.diagram-container.dragging {
    cursor: grabbing;
}

.diagram-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    transform-origin: 0 0;
}

.diagram-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
}

/* Mermaid diagram styling */
.diagram-content .mermaid {
    max-width: none !important;
    width: auto !important;
    height: auto !important;
}

/* Loading spinner */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2c3e50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error message */
.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-width: 400px;
    width: 90%;
}

.error-message h3 {
    color: #e74c3c;
    margin-bottom: 10px;
}

.error-message p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.error-message button {
    background: #2c3e50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.error-message button:hover {
    background: #34495e;
}

/* Overlay for mobile */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

/* Mobile styles */
@media (max-width: 768px) {
    .app-container {
        grid-template-areas: 
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr;
    }

    .menu-toggle {
        display: flex;
    }

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

    .zoom-controls {
        gap: 3px;
    }

    .zoom-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .sidebar {
        position: fixed;
        top: 60px;
        left: -280px;
        width: 280px;
        height: calc(100vh - 60px);
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .sidebar.open {
        left: 0;
    }

    .overlay.active {
        display: block;
    }

    .diagram-content {
        padding: 10px;
    }

    /* Mobile menu toggle animation */
    .menu-toggle.active span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }

    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.active span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .header {
        padding: 0 15px;
    }

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

    .zoom-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .sidebar {
        width: 260px;
        left: -260px;
    }

    .file-item {
        padding: 10px 15px;
        font-size: 13px;
    }

    .sidebar-header {
        padding: 15px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .file-item:hover {
        background: none;
        color: #555;
    }

    .file-item:active {
        background: #f0f0f0;
    }

    .zoom-btn:hover {
        background: rgba(255,255,255,0.1);
        border-color: rgba(255,255,255,0.2);
    }

    .zoom-btn:active {
        background: rgba(255,255,255,0.3);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .diagram-content .mermaid {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .header,
    .sidebar,
    .zoom-controls {
        display: none !important;
    }

    .app-container {
        grid-template-areas: "main";
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }

    .main-content {
        overflow: visible;
    }

    .diagram-wrapper {
        transform: none !important;
    }
}
