/* =========================================
   1. GLOBAL & STUDIO VARIABLES
   ========================================= */
:root {
    --primary: #F97316;
    --primary-hover: #EA580C;
    --secondary: #E11D48;
    --dark-bg: #0F172A;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --studio-bg: #0a0a0a;
    --panel-bg: rgba(20, 20, 20, 0.95);
    --canvas-bg: #121212;
    --border-color: rgba(255, 255, 255, 0.1);
    --radius-lg: 16px;
    --success-color: #22c55e;
    --danger-color: #ef4444;
}

/* Studio Layout */
.studio-wrapper {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    grid-template-rows: calc(100vh - 110px);
    gap: 16px;
    padding: 0 20px 20px 20px;
    box-sizing: border-box;
    overflow: hidden;
    margin-top: 100px;
}

/* Panels */
.studio-panel {
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    min-height: 60px;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.badge-premium {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: black;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
}

.badge-count {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.panel-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
}

/* Center Canvas */
.studio-canvas {
    background-color: var(--canvas-bg);
    background-image:
        linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
    background-size: 20px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
}

/* =========================================
   ANNOTATION SPECIFIC STYLES
   ========================================= */

/* File Info */
.file-info-section {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
}

.file-info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.file-info-label {
    color: var(--text-muted);
}

.file-info-value {
    color: white;
    font-weight: 600;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    white-space: nowrap;
}

/* Tool Grid (2x2) */
.tool-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.tool-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.tool-card i {
    font-size: 1.2rem;
}

.tool-card span {
    font-size: 0.75rem;
    font-weight: 600;
}

.tool-card:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.tool-card.active {
    background: rgba(249, 115, 22, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

/* Properties Box */
.properties-box {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 10px;
}

.dark-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: white;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.dark-input:focus {
    outline: none;
    border-color: var(--primary);
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="color"] {
    width: 40px;
    height: 30px;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
}

#colorHex {
    font-family: monospace;
    font-size: 0.9rem;
    color: #ccc;
}

/* Canvas Area */
.preview-stage {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.annotation-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#c {
    max-width: 100%;
    max-height: 100%;
}

.upper-canvas {
    cursor: crosshair;
}

/* Fabric.js top canvas */

/* Floating Controls (Zoom/Pan) */
.canvas-floating-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
}

.float-btn {
    background: transparent;
    border: none;
    color: #ccc;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.float-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.float-btn.active {
    background: var(--primary);
    color: white;
}

.zoom-text {
    font-size: 0.8rem;
    color: white;
    min-width: 45px;
    text-align: center;
}

.divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
}

/* Annotation List */
.annotations-list-container {
    flex: 1;
    min-height: 200px;
    max-height: 400px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 10px;
    overflow-y: auto;
    padding: 5px;
}

.anno-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.anno-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.anno-item.selected {
    background: rgba(249, 115, 22, 0.1);
    border-left: 3px solid var(--primary);
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.anno-name {
    flex: 1;
    font-size: 0.85rem;
    color: #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.del-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    font-size: 1.1rem;
}

.del-btn:hover {
    color: var(--danger-color);
}

/* Upload & Empty States */
.upload-area-large {
    text-align: center;
    padding: 60px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area-large:hover {
    border-color: var(--primary);
    background: rgba(249, 115, 22, 0.05);
}

.upload-icon-large {
    font-size: 4rem;
    color: rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
}

.cost-pill {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: inline-block;
    margin: 10px 0;
    border: 1px solid var(--border-color);
}

.info-box-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    opacity: 0.6;
}

.info-box-empty i {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
}

/* Buttons */
.btn-full {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #EA580C);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
}

.btn-link-danger {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
}

.btn-link-danger:hover {
    color: var(--danger-color);
}

/* Responsive */
@media (max-width: 1200px) {
    .studio-wrapper {
        grid-template-columns: 260px 1fr 260px;
    }
}

@media (max-width: 768px) {
    .studio-wrapper {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .studio-panel,
    .studio-canvas {
        height: auto;
        min-height: 400px;
    }

    .studio-canvas {
        order: 1;
        height: 500px;
    }

    .studio-panel:first-of-type {
        order: 2;
    }

    .studio-panel:last-of-type {
        order: 3;
    }

    .tool-grid-2x2 {
        grid-template-columns: repeat(4, 1fr);
    }
}