/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

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

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

/* Controls Panel */
.controls-panel {
    background: #f8f9fa;
    padding: 25px;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    max-height: 80vh;
}

.measurement-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.4rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.measurement-group {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.measurement-group label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.input-group input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.unit {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 500;
}

.margin-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ecf0f1;
}

.margin-controls label {
    font-size: 0.85rem;
    color: #7f8c8d;
    display: flex;
    align-items: center;
    gap: 8px;
}

.margin-controls input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.85rem;
}

/* Curve Controls Section */
.curve-controls-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #e8f4fd;
    background: linear-gradient(135deg, #f8fcff 0%, #e8f4fd 100%);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.curve-controls-section h3 {
    color: #2980b9;
    margin-bottom: 20px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.curve-controls-section h3:before {
    content: "📐";
    font-size: 1rem;
}

.curve-group {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.curve-group h4 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 600;
}

.curve-input-group {
    margin-bottom: 12px;
}

.curve-input-group label {
    display: block;
    font-weight: 500;
    color: #34495e;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.curve-input-group .input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.curve-input-group .input-group input {
    flex: 1;
    padding: 6px 10px;
    border: 2px solid #e0e6ed;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
    max-width: 80px;
}

.curve-input-group .input-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.curve-input-group .unit {
    font-size: 0.85rem;
    color: #7f8c8d;
    font-weight: 500;
}

.curve-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
}

.curve-actions .tool-btn {
    flex: 1;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.curve-actions .tool-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

/* Tools Section */
.tools-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #ecf0f1;
}

.tools-section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.tool-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.tool-btn {
    padding: 10px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tool-btn:hover {
    background: #3498db;
    color: white;
}

.tool-btn.active {
    background: #3498db;
    color: white;
}

.export-section h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1rem;
}

.export-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.2s ease;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Canvas Container */
.canvas-container {
    display: flex;
    flex-direction: column;
    background: white;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.canvas-header h3 {
    color: #2c3e50;
    font-size: 1.3rem;
}

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

.zoom-controls button {
    width: 35px;
    height: 35px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.zoom-controls button:hover {
    background: #3498db;
    color: white;
}

/* SVG Container */
.svg-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: #fafbfc;
    position: relative;
    overflow: hidden;
}

#patternCanvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* SVG Styles */
svg * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

svg {
    overflow: visible;
}

/* Disable pointer events on non-interactive elements */
.inch-label {
    font-family: Arial, sans-serif;
    font-size: 11px;
    fill: #666;
    font-weight: 600;
    pointer-events: none;
}

.construction-lines line {
    stroke: #bdc3c7;
    stroke-width: 1;
    stroke-dasharray: 3,3;
    pointer-events: none;
}

.construction-lines {
    pointer-events: none;
}

.pattern-fill {
    fill: rgba(52, 152, 219, 0.15);
    stroke: #2c3e50;
    stroke-width: 2;
    pointer-events: none;
}

.armhole-curve {
    stroke: #e74c3c;
    stroke-width: 3;
    fill: none;
    pointer-events: none;
}

.side-seam-curve {
    stroke: #9b59b6;
    stroke-width: 3;
    fill: none;
    pointer-events: none;
}

/* Grid elements should not interfere */
#gridBackground, #majorGridBackground {
    pointer-events: none;
}

#inchMarkers {
    pointer-events: none;
}

.pattern-points {
    pointer-events: all;
    z-index: 100;
}

.pattern-points circle {
    fill: #e74c3c;
    stroke: white;
    stroke-width: 2;
    r: 3;
    transition: fill 0.2s ease, r 0.2s ease;
    pointer-events: all !important;
    transform-origin: center;
}

.pattern-points circle:hover {
    r: 4;
    fill: #c0392b;
}

.pattern-points circle.dragging {
    fill: #27ae60;
    r: 5;
}

.point-labels text {
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: bold;
    fill: #2c3e50;
    text-anchor: start;
    pointer-events: none !important;
    user-select: none;
}

.point-labels {
    pointer-events: none !important;
}

.control-points {
    pointer-events: all;
    z-index: 90;
}

.control-points circle {
    fill: rgba(39, 174, 96, 0.8);
    stroke: #27ae60;
    stroke-width: 2;
    cursor: grab;
    r: 4;
    transition: fill 0.2s ease, opacity 0.2s ease, stroke-width 0.2s ease, r 0.2s ease;
    opacity: 0.7;
    pointer-events: all !important;
    transform-origin: center;
}

.control-points circle:hover {
    fill: #2ecc71;
    stroke: #27ae60;
    stroke-width: 3;
    r: 5;
    opacity: 1;
    cursor: grab;
}

.control-points circle.dragging {
    fill: #27ae60;
    stroke: #2ecc71;
    r: 6;
    opacity: 1;
    cursor: grabbing !important;
}

.control-points circle.side-seam {
    fill: rgba(39, 174, 96, 0.8);
    stroke: #27ae60;
}

.control-points circle.side-seam:hover {
    fill: #2ecc71;
    stroke: #27ae60;
    cursor: grab;
}

.control-points line {
    stroke: rgba(156, 174, 39, 0.5);
    stroke-width: 1;
    stroke-dasharray: 2,2;
    pointer-events: none;
}

.control-points line.side-seam {
    stroke: rgba(39, 174, 96, 0.5);
    pointer-events: none;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: #34495e;
    color: white;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
}

.status-bar span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 300px 1fr;
        gap: 20px;
    }
    
    .controls-panel {
        padding: 20px;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .controls-panel {
        max-height: none;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .tool-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .canvas-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .tool-buttons {
        grid-template-columns: 1fr 1fr;
    }
    
    #patternCanvas {
        width: 100%;
        height: auto;
    }
}