* {
    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;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.5rem;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 320px;
    background-color: white;
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid #ddd;
}

.control-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.control-section h3 {
    font-size: 0.95rem;
    margin: 1rem 0 0.5rem 0;
    color: #34495e;
}

.btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    width: 100%;
    margin-bottom: 0.5rem;
}

.btn:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    display: inline-block;
    width: auto;
    margin-right: 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

#imageUpload {
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.calibration-status {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    text-align: center;
}

.calibration-status.calibrated {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}

#calibrationInputs {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 4px;
}

#calibrationInputs label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
}

#calibrationInputs input {
    width: calc(100% - 80px);
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

#calibrationInputs select {
    width: 70px;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.span-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.span-length {
    flex: 1;
    padding: 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.unit-label {
    font-size: 0.85rem;
    color: #666;
    width: 30px;
}

.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #ecf0f1;
}

.canvas-controls {
    background-color: white;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #ddd;
}

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

.zoom-hint {
    margin-left: auto;
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
}

.canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    overflow: auto;
}

#mainCanvas {
    background-color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: crosshair;
    max-width: 100%;
    max-height: 100%;
}

.canvas-info {
    background-color: white;
    padding: 0.5rem 1rem;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
}

.pivot-item,
.boundary-item {
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pivot-item button,
.boundary-item button {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
}

.pivot-item button:hover,
.boundary-item button:hover {
    background-color: #c0392b;
}

.pivot-item.selected {
    background-color: #d4edda;
    border: 2px solid #28a745;
}

.quick-add-spans {
    margin-bottom: 0.5rem;
}

.quick-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.3rem;
}

.btn-quick {
    padding: 0.4rem 0.3rem;
    font-size: 0.8rem;
    background-color: #16a085;
    margin: 0;
}

.btn-quick:hover {
    background-color: #138d75;
}

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

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

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

.modal-close:hover {
    color: #000;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}
