/* Board Cut Calculator Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.5;
}

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

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.header h1 {
    font-size: 1.5rem;
    color: #1a237e;
}

.header-actions a {
    color: #666;
    text-decoration: none;
    font-size: 0.85rem;
}

.header-actions a:hover { color: #1a73e8; }

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

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

/* Cards */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 24px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

/* Form elements */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}

/* Board info badge */
.board-info {
    background: #e8eaf6;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #333;
    margin-bottom: 16px;
    display: none;
}

.board-info strong { color: #1a237e; }

/* Piece rows */
.piece-list { margin-bottom: 12px; }

.piece-row {
    background: #f8f9ff;
    border: 1px solid #e8eaf6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    position: relative;
}

.piece-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.piece-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
}

.piece-remove {
    background: none;
    border: none;
    color: #d32f2f;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
}

.piece-remove:hover { background: #ffebee; }

.piece-fields {
    display: grid;
    grid-template-columns: 1fr 100px 100px 70px;
    gap: 8px;
    align-items: end;
}

.piece-fields .field label {
    display: block;
    font-size: 0.72rem;
    color: #777;
    margin-bottom: 2px;
    font-weight: 600;
}

.piece-fields .field input,
.piece-fields .field select {
    width: 100%;
    padding: 7px 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

.piece-fields .field input:focus,
.piece-fields .field select:focus {
    outline: none;
    border-color: #1a73e8;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 9px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: #1a73e8;
    color: #fff;
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

.btn-primary:hover { background: #1557b0; }
.btn-primary:disabled { background: #999; cursor: not-allowed; }

.btn-secondary {
    background: #e8eaf6;
    color: #333;
    font-size: 0.85rem;
    padding: 7px 14px;
}

.btn-secondary:hover { background: #c5cae9; }

.btn-add-piece {
    width: 100%;
    text-align: center;
    margin-bottom: 16px;
}

/* Results */
.results-area {
    min-height: 200px;
}

.results-empty {
    text-align: center;
    color: #aaa;
    padding: 60px 20px;
    font-size: 0.95rem;
}

/* Recommendation banner */
.recommendation {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    color: #1565c0;
}

.recommendation strong { color: #0d47a1; }

/* Board result card */
.board-result {
    margin-bottom: 24px;
}

.board-result h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: #333;
}

.board-result .usage-bar {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin-bottom: 12px;
    overflow: hidden;
}

.board-result .usage-bar-fill {
    height: 100%;
    background: #43a047;
    border-radius: 3px;
    transition: width 0.5s;
}

.board-result .usage-text {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 10px;
}

.svg-container {
    overflow-x: auto;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 16px;
}

.svg-container svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Pricing table */
.pricing-card {
    margin-top: 20px;
}

.pricing-card h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: #333;
}

.pricing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.pricing-table th,
.pricing-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.pricing-table th {
    background: #f5f7fa;
    font-weight: 600;
    color: #555;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.pricing-table tr:hover td { background: #f8f9ff; }

.pricing-table .total-row {
    font-weight: 700;
    background: #f0f4ff;
}

.pricing-table .waste-row { color: #d32f2f; }

/* Summary stats */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-box {
    background: #f5f7fa;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}

.stat-box .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a237e;
}

.stat-box .stat-label {
    font-size: 0.75rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #ddd;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 10px;
}

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

/* Error message */
.error-msg {
    background: #ffebee;
    color: #c62828;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid #ffcdd2;
    margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 600px) {
    .piece-fields {
        grid-template-columns: 1fr 1fr;
    }
    .summary-stats {
        grid-template-columns: 1fr 1fr;
    }
}
