* {
    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%);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

h1 {
    font-size: 2em;
    margin-bottom: 10px;
}

.subtitle {
    opacity: 0.9;
    font-size: 1.1em;
}

.content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 0;
    min-height: 600px;
}

.sidebar {
    background: #f8f9fa;
    padding: 30px;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
}

.main {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section {
    margin-bottom: 25px;
}

.section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.1em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.validation-results {
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.validation-results.valid {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.validation-results.invalid {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.validation-results h4 {
    margin-bottom: 10px;
    font-size: 1em;
}

.validation-results ul {
    margin-left: 20px;
}

.validation-results li {
    margin-bottom: 5px;
}

.pattern-info {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #495057;
}

.info-value {
    color: #6c757d;
}

.canvas-container {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.canvas-viewport {
    overflow: auto;
    max-height: calc(100vh - 260px);
    width: 100%;
}

canvas {
    display: block;
    border: 1px solid #adb5bd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-control span {
    color: #495057;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 24px;
    height: 24px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    pointer-events: none;
    display: none;
    z-index: 1000;
}

/* Tab Navigation */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 20px;
}

.tab-button {
    flex: 1;
    background: transparent;
    color: #6c757d;
    border: none;
    padding: 12px 10px;
    border-radius: 0;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    transform: none;
    box-shadow: none;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.tab-content {
    display: block;
}

.tab-content.hidden {
    display: none;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input.input-valid {
    border-color: #28a745;
}

.form-input.input-error {
    border-color: #dc3545;
}

.form-input-inline {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 4px 8px;
    font-weight: 600;
    font-size: 1.1em;
    transition: border-color 0.2s;
}

.form-input-inline:hover {
    border-bottom-color: #dee2e6;
}

.form-input-inline:focus {
    outline: none;
    border-bottom-color: #667eea;
    box-shadow: none;
}

/* Helper and Error Messages */
.helper-text {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 6px;
}

.error-message {
    font-size: 0.85em;
    color: #dc3545;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.success-message {
    font-size: 0.85em;
    color: #28a745;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Color Picker */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.color-picker-group input[type="color"] {
    width: 50px;
    height: 40px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

.color-picker-group input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.95em;
}

.color-picker-group input[type="number"] {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.95em;
}

/* Section Cards */
.section-card {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.section-card:hover {
    border-color: #667eea;
}

.section-card-header {
    background: #f8f9fa;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
    gap: 10px;
}

.section-reorder-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reorder-btn {
    background: white;
    color: #667eea;
    border: 1px solid #667eea;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    line-height: 1;
    transition: all 0.2s;
}

.reorder-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    transform: none;
    box-shadow: none;
}

.reorder-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.section-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-card-header input.section-name {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    font-size: 1.05em;
    padding: 4px 8px;
    transition: border-color 0.2s;
    flex: 1;
}

.section-card-header input.section-name:hover {
    border-bottom-color: #dee2e6;
}

.section-card-header input.section-name:focus {
    outline: none;
    border-bottom-color: #667eea;
}

.section-technique {
    color: #6c757d;
    font-size: 0.9em;
    padding: 4px 12px;
    background: white;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.section-card-body {
    padding: 15px;
}

.delete-btn {
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    line-height: 1;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: #dc3545;
    color: white;
    transform: none;
    box-shadow: none;
}

.add-section-btn {
    width: 100%;
    margin-top: 15px;
    padding: 12px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1em;
}

.add-section-btn:hover {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.total-length {
    font-size: 1.1em;
    font-weight: 600;
    color: #495057;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #dee2e6;
    text-align: center;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.quick-actions button {
    flex: 1;
    padding: 10px;
    font-size: 0.9em;
}

/* Pattern Type Radio */
.pattern-type-group {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.pattern-type-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.pattern-type-option input[type="radio"] {
    cursor: pointer;
}

/* Warp Preview Bar */
.warp-preview {
    height: 40px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    margin-top: 15px;
    display: flex;
    overflow: hidden;
}

.warp-preview-thread {
    flex: 1;
    min-width: 2px;
}

/* Header Actions */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    flex: 1;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-actions button {
    padding: 8px 16px;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: none;
}

@media (max-width: 1024px) {
    .content {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        gap: 15px;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions button {
        flex: 1;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-button {
        flex: 1 1 45%;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4em;
}

.modal-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.modal-close:hover {
    transform: none;
    box-shadow: none;
    opacity: 0.8;
}

.modal-body {
    padding: 30px;
}

/* Yarn Calculator Styles */
.yarn-section {
    margin-bottom: 25px;
}

.yarn-section h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.yarn-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.yarn-table th {
    background: #f8f9fa;
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.yarn-table td {
    padding: 10px;
    border-bottom: 1px solid #e9ecef;
}

.yarn-table tr.total-row {
    background: #f8f9fa;
    font-weight: 600;
}

.color-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    margin-right: 8px;
    vertical-align: middle;
}

.yarn-note {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.shopping-list td {
    font-size: 0.95em;
}
