/* CSS Variables for Theming */
:root {
    --bg-primary: #ffffff;
    --bg-primary-rgb: 255, 255, 255;
    --bg-secondary: #f8fafc;
    --bg-secondary-rgb: 248, 250, 252;
    --bg-tertiary: #f1f5f9;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-secondary-rgb: 74, 85, 104;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --border-color-rgb: 226, 232, 240;
    --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-heavy: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --node-stroke: #ffffff;
    --link-stroke: #718096;
    --text-fill: #2d3748;
    --primary-color: #1a365d;
    --secondary-color: #3182ce;
    --accent-color: #38a169;
}

[data-theme="dark"] {
    --bg-primary: #1a202c;
    --bg-primary-rgb: 26, 32, 44;
    --bg-secondary: #2d3748;
    --bg-secondary-rgb: 45, 55, 72;
    --bg-tertiary: #4a5568;
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-secondary-rgb: 226, 232, 240;
    --text-muted: #a0aec0;
    --border-color: #4a5568;
    --border-color-rgb: 74, 85, 104;
    --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-heavy: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    --node-stroke: #2d3748;
    --link-stroke: #a0aec0;
    --text-fill: #f7fafc;
}

/* 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: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, #1a365d 0%, #2d3748 100%);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 60px;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    margin: 0;
    flex: 1;
    min-width: 0;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1rem;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-height: 40vh;
    flex-shrink: 0;
}

.sidebar-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.sidebar-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.sidebar-section h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    background: var(--bg-secondary);
    position: relative;
    min-height: 60vh;
}

.canvas {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

/* Buttons */
.btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.025em;
    white-space: nowrap;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.btn-primary {
    background: #3182ce;
    color: white;
}

.btn-primary:hover {
    background: #2c5aa0;
}

.btn-secondary {
    background: #4a5568;
    color: white;
}

.btn-secondary:hover {
    background: #2d3748;
}

.btn-success {
    background: #38a169;
    color: white;
}

.btn-success:hover {
    background: #2f855a;
}

.btn-danger {
    background: #e53e3e;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-outline {
    background: transparent;
    color: #3182ce;
    border: 1px solid #3182ce;
}

.btn-outline:hover {
    background: #3182ce;
    color: white;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.5;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    background-color: #ffffff;
    touch-action: manipulation;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    font-size: 0.875rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.5;
}

/* Guidelines */
.guidelines {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.guidelines ul {
    margin-left: 1.25rem;
    margin-bottom: 1rem;
}

.guidelines li {
    margin-bottom: 0.5rem;
}

/* Element Properties */
.no-selection {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
}

.element-property {
    margin-bottom: 0.75rem;
}

.element-property label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.element-property input,
.element-property select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.15s ease-in-out;
}

.element-property input:focus,
.element-property select:focus {
    outline: none;
    border-color: #3182ce;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 1.5rem;
    border-radius: 12px;
    width: 95%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    color: #718096;
    float: right;
    font-size: 24px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s ease-in-out;
    padding: 0.25rem;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: #2d3748;
}

.modal h2 {
    margin-bottom: 1.5rem;
    color: #1a202c;
    font-weight: 600;
}

/* D3.js Node Styles */
.node {
    cursor: pointer;
    stroke: var(--node-stroke);
    stroke-width: 3px;
    transition: stroke-width 0.15s ease-in-out;
}

.node:hover {
    stroke: #3182ce;
    stroke-width: 4px;
}

.node.selected {
    stroke: #38a169;
    stroke-width: 4px;
}

.node.highlighted {
    stroke: #2196f3;
    stroke-width: 3px;
    filter: drop-shadow(0 0 5px #2196f3);
}

.node text {
    font-size: 12px;
    font-weight: 500;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    fill: var(--text-fill);
}

/* D3.js Link Styles */
.link {
    stroke: var(--link-stroke);
    stroke-width: 3px;
    fill: none;
    cursor: pointer;
    transition: stroke-width 0.15s ease-in-out;
}

.link:hover {
    stroke: #007bff;
    stroke-width: 4px;
}

.link.selected {
    stroke: #28a745;
    stroke-width: 4px;
}

.link.highlighted {
    stroke: #2196f3;
    stroke-width: 4px;
    filter: drop-shadow(0 0 3px #2196f3);
}

.link-label {
    font-size: 10px;
    font-weight: bold;
    fill: #666;
    text-anchor: middle;
    dominant-baseline: middle;
}

/* Loop Styles */
.loop {
    stroke: #ff6b6b;
    stroke-width: 2px;
    fill: none;
    stroke-dasharray: 5,5;
    opacity: 0.7;
}

.loop-label {
    font-size: 11px;
    font-weight: bold;
    fill: #ff6b6b;
    text-anchor: middle;
    dominant-baseline: middle;
}

/* Guidance Text */
.guidance-text {
    margin-top: 10px;
    padding: 8px;
    background: #f0f8ff;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #333;
    line-height: 1.4;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}

/* Loop Analysis */
.no-loops {
    color: #999;
    font-style: italic;
    font-size: 0.875rem;
}

.loop-item {
    margin-bottom: 15px;
    padding: 10px;
    border-left: 3px solid #ff6b6b;
    background: #f8f9fa;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.loop-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Sidebar Text Normalization */
.sidebar {
    font-size: 0.875rem;
    line-height: 1.5;
}

.sidebar p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.sidebar div {
    font-size: 0.875rem;
    line-height: 1.5;
}

.sidebar strong {
    font-weight: 600;
    color: var(--text-primary);
}

.no-analysis {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
}

.optimization-info p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.optimization-status p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.improvement-item {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}



/* Prevent text selection on interactive elements */
.node, .link, .btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Desktop Layout */
@media (min-width: 1024px) {
    .header {
        padding: 1.25rem 2rem;
    }
    
    .header h1 {
        font-size: 1.75rem;
    }
    
    .main-content {
        flex-direction: row;
    }
    
    .sidebar {
        width: 300px;
        max-height: none;
        height: 100%;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        padding: 1.5rem;
    }
    
    .canvas-area {
        flex: 1;
    }
}

/* Tablet Layout */
@media (min-width: 768px) and (max-width: 1023px) {
    .header {
        padding: 1rem 1.5rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .sidebar {
        max-height: 35vh;
    }
}

/* Mobile Landscape */
@media (max-width: 767px) and (orientation: landscape) {
    .main-content {
        flex-direction: row;
    }
    
    .sidebar {
        width: 40%;
        max-height: none;
        height: 100%;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
    }
    
    .canvas-area {
        width: 60%;
    }
    
    .header h1 {
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* ===== FOOTER STYLES ===== */
/* Separate, clean footer implementation to avoid CSS conflicts */

.footer {
    /* Reset any inherited styles */
    all: unset;
    display: block;
    
    /* Distinctive gradient background with animation - using !important to override conflicts */
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 1) 0%, 
        rgba(240, 245, 250, 0.95) 25%, 
        rgba(230, 240, 250, 0.9) 50%, 
        rgba(240, 245, 250, 0.95) 75%, 
        rgba(255, 255, 255, 1) 100%) !important;
    background-size: 200% 200% !important;
    animation: footerDrift 12s ease-in-out infinite !important;
    
    /* Visual styling */
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    padding: 1.25rem 2rem;
    position: relative;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    font-family: inherit;
    line-height: 1.4;
}

/* Footer animation */
@keyframes footerDrift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Footer top border */
.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--border-color) 20%, var(--border-color) 80%, transparent 100%);
}

/* Footer content container */
.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 3rem;
    align-items: center;
    position: relative;
}

/* Footer sections */
.footer-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Center donation section */
.footer-section:nth-child(2) {
    text-align: center;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, 
        rgba(248, 250, 252, 0.8) 0%, 
        rgba(241, 245, 249, 0.7) 100%) !important;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.4);
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.footer-section:nth-child(2):hover {
    background: linear-gradient(135deg, 
        rgba(248, 250, 252, 0.9) 0%, 
        rgba(241, 245, 249, 0.8) 100%);
    border-color: rgba(226, 232, 240, 0.6);
    transform: translateY(-1px);
}

/* Copyright text */
.copyright {
    color: var(--text-muted);
    font-weight: 400;
    margin: 0;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.copyright strong {
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Contact section */
.contact {
    margin: 0;
}

.contact a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 400;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid transparent;
}

.contact a:hover {
    color: var(--text-secondary);
    background: rgba(248, 250, 252, 0.8);
    border-color: rgba(226, 232, 240, 0.5);
    transform: translateY(-1px);
}

/* Donation section */
.donation-link {
    display: flex;
    align-items: center;
    justify-content: center;
}

.donation-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.donation-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(74, 85, 104, 0.05), transparent);
    transition: left 0.3s ease;
}

.donation-btn:hover::before {
    left: 100%;
}

.donation-btn:hover {
    color: var(--text-secondary);
    background: rgba(248, 250, 252, 0.9);
    border-color: rgba(226, 232, 240, 0.6);
    transform: translateY(-1px);
}

/* Footer responsive adjustments */
@media (max-width: 1024px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-section:nth-child(2) {
        order: -1;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 768px) {
    .footer {
        padding: 1rem 1.5rem;
    }
    
    .footer-content {
        gap: 1.5rem;
    }
    
    .footer-section:nth-child(2) {
        padding: 0.625rem 1.25rem;
    }
    
    .donation-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.7rem;
    }
} 