/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --get-color: #22c55e;
    --post-color: #3b82f6;
    --put-color: #f59e0b;
    --delete-color: #ef4444;
    --patch-color: #8b5cf6;
    --schema-color: #06b6d4;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--schema-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-container {
    max-width: 600px;
    margin: 0 auto;
}

.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-area h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.sample-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

/* Controls Section */
.controls-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.controls-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.control-group input,
.control-group select {
    padding: 0.6rem 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 180px;
    transition: var(--transition);
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.control-group.buttons {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.control-group.export-buttons {
    flex-direction: row;
    margin-left: auto;
    gap: 0.5rem;
}

/* Visualization Section */
.visualization-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.visualization-container {
    display: flex;
    gap: 1rem;
    height: 600px;
    position: relative;
}

.canvas-wrapper {
    flex: 1;
    background: var(--background);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

#dependencyGraph {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#dependencyGraph:active {
    cursor: grabbing;
}

/* Info Panel */
.info-panel {
    width: 320px;
    background: var(--surface-light);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.info-panel.hidden {
    width: 0;
    padding: 0;
    overflow: hidden;
}

.info-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.info-panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.close-panel-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-panel-btn:hover {
    color: var(--text-primary);
}

.info-panel-content {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.placeholder-text {
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

.info-section {
    margin-bottom: 1rem;
}

.info-section h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-section p,
.info-section ul {
    font-size: 0.9rem;
}

.info-section ul {
    list-style: none;
    padding: 0;
}

.info-section li {
    padding: 0.25rem 0;
    color: var(--text-secondary);
}

.method-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.method-badge.get { background: var(--get-color); color: white; }
.method-badge.post { background: var(--post-color); color: white; }
.method-badge.put { background: var(--put-color); color: white; }
.method-badge.delete { background: var(--delete-color); color: white; }
.method-badge.patch { background: var(--patch-color); color: white; }

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.endpoint-get { background: var(--get-color); }
.legend-color.endpoint-post { background: var(--post-color); }
.legend-color.endpoint-put { background: var(--put-color); }
.legend-color.endpoint-delete { background: var(--delete-color); }
.legend-color.endpoint-patch { background: var(--patch-color); }
.legend-color.schema { background: var(--schema-color); }

/* Stats Section */
.stats-section {
    margin-bottom: 2rem;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-color);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.error { border-left: 4px solid var(--error); }

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Graph Node Styles */
.node {
    cursor: pointer;
}

.node rect,
.node circle {
    transition: var(--transition);
}

.node:hover rect,
.node:hover circle {
    filter: brightness(1.2);
}

.node.expanded rect,
.node.expanded circle {
    stroke: var(--primary-color);
    stroke-width: 3px;
}

.node text {
    font-family: inherit;
    font-size: 12px;
    fill: var(--text-primary);
    pointer-events: none;
}

.link {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 1.5px;
    opacity: 0.6;
}

.link.highlighted {
    stroke: var(--primary-color);
    stroke-width: 2.5px;
    opacity: 1;
}

/* Expand/Collapse Button */
.expand-btn {
    cursor: pointer;
    fill: var(--surface-light);
    stroke: var(--text-secondary);
}

.expand-btn:hover {
    fill: var(--primary-color);
    stroke: white;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .visualization-container {
        flex-direction: column;
        height: auto;
    }

    .canvas-wrapper {
        height: 400px;
    }

    .info-panel {
        width: 100%;
        max-height: 300px;
    }

    .control-group.export-buttons {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
}

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

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

    .controls-container {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        width: 100%;
    }

    .control-group input,
    .control-group select {
        min-width: 100%;
    }

    .control-group.buttons {
        flex-wrap: wrap;
    }

    .btn {
        flex: 1;
        min-width: 100px;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

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

    .canvas-wrapper {
        height: 350px;
    }

    .legend {
        justify-content: center;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .logo-section {
        flex-direction: column;
        gap: 0.5rem;
    }

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

    .tagline {
        font-size: 0.9rem;
    }

    .sample-section {
        flex-direction: column;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 10;
}

.zoom-btn {
    width: 36px;
    height: 36px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.zoom-btn:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
}

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

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Node Tooltip */
.node-tooltip {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.75rem;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    z-index: 100;
    max-width: 300px;
    font-size: 0.85rem;
}

.node-tooltip h4 {
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.node-tooltip p {
    color: var(--text-secondary);
    margin: 0;
}
