/* TapeRoof Studio */
@import url('../../assets/taperoof-theme.css');

:root {
    --st-primary: var(--tr-primary);
    --st-accent: var(--tr-accent);
    --st-bg: var(--tr-bg-alt);
    --st-white: var(--tr-white);
    --st-border: var(--tr-border);
    --st-text: var(--tr-text);
    --st-muted: var(--tr-text-muted);
    --st-danger: #dc2626;
    --st-radius: 8px;
    --st-font: var(--tr-font);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.studio {
    font-family: var(--st-font);
    color: var(--st-text);
    background: var(--st-bg);
    min-height: 100vh;
}

.studio-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--st-white);
    border-bottom: 1px solid var(--st-border);
    flex-wrap: wrap;
}

.studio-logo {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--st-primary);
    text-decoration: none;
}

.studio-logo span { color: var(--st-accent); }

.studio-header__project {
    flex: 1;
    min-width: 200px;
    font-size: 0.85rem;
}

.studio-header__project span {
    display: block;
    color: var(--st-muted);
}

.studio-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.studio-nav a {
    text-decoration: none;
    color: var(--st-muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.studio-nav a.is-active { color: var(--st-primary); }

.studio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--st-radius);
    border: 1px solid var(--st-border);
    background: var(--st-white);
    color: var(--st-text);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
}

.studio-btn--primary {
    background: var(--st-accent);
    border-color: var(--st-accent);
    color: #fff;
}

.studio-btn--primary:hover { filter: brightness(0.95); }

.studio-btn--danger {
    border-color: var(--st-danger);
    color: var(--st-danger);
}

.studio-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

.studio-main--narrow { max-width: 720px; }

.studio-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.studio-lead { color: var(--st-muted); margin-bottom: 1.5rem; }

.studio-empty {
    text-align: center;
    padding: 3rem;
    background: var(--st-white);
    border-radius: var(--st-radius);
    border: 1px dashed var(--st-border);
}

.studio-table-wrap {
    background: var(--st-white);
    border-radius: var(--st-radius);
    overflow: hidden;
    border: 1px solid var(--st-border);
}

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

.studio-table th, .studio-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--st-border);
}

.studio-table th {
    background: #f8fafc;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--st-muted);
}

.studio-actions { white-space: nowrap; }
.studio-actions a { margin-left: 0.75rem; color: var(--st-primary); font-weight: 600; text-decoration: none; }

.studio-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: #ebf5fb;
    color: var(--st-primary);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.studio-form fieldset {
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--st-white);
}

.studio-form legend {
    font-weight: 700;
    color: var(--st-primary);
    padding: 0 0.35rem;
}

.studio-form label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.studio-form input, .studio-form select, .studio-form textarea {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--st-border);
    border-radius: 6px;
    font: inherit;
}

.studio-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.studio-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.studio-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--st-radius);
    margin-bottom: 1rem;
}

.studio-alert--error {
    background: #fdf0f0;
    border: 1px solid #e74c3c;
    color: #922b21;
}

.studio-tabs {
    display: flex;
    gap: 0;
    background: var(--st-white);
    border-bottom: 1px solid var(--st-border);
    overflow-x: auto;
    padding: 0 1rem;
}

.studio-tabs a {
    padding: 0.85rem 1rem;
    text-decoration: none;
    color: var(--st-muted);
    font-weight: 600;
    font-size: 0.875rem;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.studio-tabs a.is-active {
    color: var(--st-primary);
    border-bottom-color: var(--st-accent);
}

.studio--editor .studio-main { max-width: none; padding: 0; }

.studio-editor { min-height: calc(100vh - 110px); }

.studio-panel {
    max-width: 900px;
    margin: 1.5rem auto;
    padding: 1.5rem;
    background: var(--st-white);
    border-radius: var(--st-radius);
    border: 1px solid var(--st-border);
}

.studio-panel--full {
    max-width: none;
    margin: 0;
    border: none;
    border-radius: 0;
    min-height: calc(100vh - 110px);
}

.studio-workspace {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: calc(100vh - 110px);
}

.studio-sidebar {
    background: var(--st-white);
    border-right: 1px solid var(--st-border);
    padding: 1rem;
    overflow-y: auto;
}

.studio-tool-group h3,
.studio-side-panel h3,
.studio-plane-list h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--st-muted);
    margin-bottom: 0.5rem;
}

.studio-tool-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.35rem;
    border: 1px solid var(--st-border);
    border-radius: 6px;
    background: #f8fafc;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}

.studio-tool-btn.is-active {
    background: var(--st-primary);
    color: #fff;
    border-color: var(--st-primary);
}

.studio-side-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--st-border);
}

.studio-hint { font-size: 0.8rem; color: var(--st-muted); margin-bottom: 0.75rem; }

.studio-area-display, .studio-scale-info {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--st-primary);
    margin: 0.75rem 0;
}

.studio-plane-list { margin-top: 1.25rem; }

.studio-plane-list ul {
    list-style: none;
    font-size: 0.85rem;
}

.studio-plane-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--st-border);
    cursor: pointer;
}

.studio-plane-list li.is-selected { color: var(--st-accent); font-weight: 700; }

.studio-canvas-wrap {
    position: relative;
    background: #2a2a2a;
    overflow: hidden;
}

#konva-container {
    width: 100%;
    height: calc(100vh - 110px);
}

.studio-status {
    position: absolute;
    bottom: 0.5rem;
    left: 0.75rem;
    background: rgba(0,0,0,0.65);
    color: #fff;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.studio-upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.studio-upload-card {
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 0.75rem;
    background: #fafbfc;
}

.studio-upload-card h3 { font-size: 0.9rem; margin-bottom: 0.5rem; }

.studio-upload-preview {
    height: 140px;
    background: #eef2f5;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.studio-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.studio-upload-placeholder { color: var(--st-muted); font-size: 0.8rem; }

.studio-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.studio-summary-card {
    background: #f8fafc;
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 0.75rem;
}

.studio-summary-card span {
    display: block;
    font-size: 0.75rem;
    color: var(--st-muted);
    text-transform: uppercase;
}

.studio-summary-card strong {
    font-size: 1.25rem;
    color: var(--st-primary);
}

.studio-report-frame {
    width: 100%;
    height: calc(100vh - 160px);
    border: 1px solid var(--st-border);
    background: #fff;
}

@media (max-width: 900px) {
    .studio-workspace { grid-template-columns: 1fr; }
    .studio-sidebar { border-right: none; border-bottom: 1px solid var(--st-border); }
    #konva-container { height: 60vh; }
}

.studio-roof-engine {
    margin-top: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--st-border);
    background: var(--st-bg);
}

.studio-roof-engine__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.studio-roof-engine__head h3 {
    margin: 0;
    flex: 1;
    font-size: 0.95rem;
    color: var(--st-primary);
}

.studio-roof-engine__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.studio-roof-engine__svg {
    background: #fff;
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    min-height: 200px;
}

.studio-roof-engine__canvas {
    height: 360px;
    background: var(--tr-bg-alt);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    overflow: hidden;
}

@media (max-width: 900px) {
    .studio-roof-engine__grid { grid-template-columns: 1fr; }
}
