/* 
  Studio Shared Design System
  Unifies the layout, sidebar, and controls across X, IG, and TikTok templates.
*/

:root {
    --sidebar-width: 350px;
    --primary-blue: #1D9BF0;
    --primary-red: #ef4444;
    --zinc-50: #fafafa;
    --zinc-100: #f4f4f5;
    --zinc-200: #e4e4e7;
    --zinc-300: #d4d4d8;
    --zinc-800: #27272a;
    --zinc-900: #18181b;
}

/* 1. Main Layout */
.studio-layout {
    display: flex;
    flex-direction: column-reverse;
    /* Mobile: Preview (2nd) on top, Sidebar (1st) at bottom */
    gap: 1.5rem;
    align-items: stretch;
    width: 100%;
}

@media (min-width: 1024px) {
    .studio-layout {
        display: grid;
        grid-template-columns: 400px 1fr;
        flex-direction: row;
        gap: 2.5rem;
        align-items: start;
    }
}

/* 2. Sidebar Styling & Spacing */
.studio-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    overflow-x: hidden;
}

.studio-card {
    padding: 1.25rem;
    border-radius: 1.25rem;
    background-color: rgba(249, 250, 251, 0.5);
    border: 1px solid #eaeaea;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

@media (min-width: 640px) {
    .studio-card {
        padding: 1.5rem;
    }
}

.dark .studio-card {
    background-color: rgba(24, 24, 27, 0.5);
    border-color: rgba(234, 234, 234, 0.1);
}

.studio-card-title {
    font-size: 0.625rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #888888;
    margin-bottom: 1rem;
}

/* 3. Inputs & Selects */
.studio-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.studio-label {
    font-size: 0.625rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}

.studio-input,
.studio-select,
.studio-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
    border-radius: 0.875rem;
    border: 1px solid #e4e4e7;
    background-color: #ffffff;
    outline: none;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
    color: #18181b;
}

.studio-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 0.75rem;
    padding-right: 2.5rem;
    cursor: pointer;
}

.dark .studio-input,
.dark .studio-select,
.dark .studio-textarea {
    background-color: #000000;
    border-color: #27272a;
    color: #fafafa;
}

.dark .studio-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2371717a' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

.studio-input:focus,
.studio-select:focus,
.studio-textarea:focus {
    box-shadow: 0 0 0 4px rgba(29, 155, 240, 0.1);
    border-color: var(--primary-blue);
    background-color: #ffffff;
}

.dark .studio-input:focus,
.dark .studio-select:focus,
.dark .studio-textarea:focus {
    background-color: #000000;
    box-shadow: 0 0 0 4px rgba(29, 155, 240, 0.15);
}

/* Range Input Styling */
.studio-input[type="range"] {
    appearance: none;
    height: 6px;
    background: #e4e4e7;
    border: none;
    padding: 0;
    cursor: pointer;
}

.dark .studio-input[type="range"] {
    background: #27272a;
}

.studio-input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-blue);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dark .studio-input[type="range"]::-webkit-slider-thumb {
    border-color: #18181b;
}

.studio-input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* 4. Buttons */
.studio-btn-primary {
    width: 100%;
    padding: 1rem;
    background-color: #000000;
    color: #ffffff;
    border-radius: 1rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
    transition: background-color 0.2s, color 0.2s, transform 0.2s, opacity 0.2s;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.dark .studio-btn-primary {
    background-color: #ffffff;
    color: #000000;
}

.studio-btn-primary:hover {
    opacity: 0.9;
}

.studio-btn-primary:active {
    transform: scale(0.98);
}

.studio-btn-reset {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background-color: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border-radius: 0.75rem;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.studio-btn-reset:hover {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.1);
    transform: translateY(-1px);
}

.studio-card-action {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background-color: rgba(29, 155, 240, 0.08);
    color: var(--primary-blue);
    border-radius: 8px;
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.studio-card-action:hover {
    background-color: rgba(29, 155, 240, 0.15);
    border-color: rgba(29, 155, 240, 0.1);
    transform: translateY(-1px);
}

.studio-remove-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 2px 6px;
    background-color: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border-radius: 6px;
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.studio-remove-btn:hover {
    background-color: #ef4444;
    color: #ffffff;
}

.studio-remove-btn svg {
    width: 10px;
    height: 10px;
}

.studio-add-btn {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border: 2px dashed #e4e4e7;
    background-color: transparent;
    color: #71717a;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.dark .studio-add-btn {
    border-color: #27272a;
    color: #a1a1aa;
}

.studio-add-btn:hover {
    background-color: rgba(29, 155, 240, 0.05);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    transform: translateY(-1px);
}

.studio-add-btn:active {
    transform: scale(0.98);
}

/* 5. Mockup Container (Live Canvas) */
.studio-mockup-viewer-container {
    overflow: visible !important;
}

.studio-mockup-viewer {
    position: relative;
    background-color: rgba(243, 244, 246, 0.5);
    border-radius: 1.25rem;
    border: 2px dashed #e5e7eb;
    align-self: flex-start;
    width: 100%;
}

@media (min-width: 768px) {
    .studio-mockup-viewer {
        border-radius: 1.875rem;
        overflow: visible !important;
        position: sticky;
        top: 2rem;
    }
}

.sticky-preview {
    position: relative;
    top: 0;
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 40;
}

#panzoom-viewport {
    width: 100%;
    height: clamp(350px, 60vh, 850px);
    cursor: grab;
    overflow: hidden;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1.25rem;
    background-image:
        radial-gradient(circle, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        radial-gradient(circle, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    transition: background-image 0.3s ease, filter 0.4s ease;
}

#panzoom-viewport.processing {
    filter: blur(10px);
    pointer-events: none;
    cursor: wait !important;
}

@media (min-width: 768px) {
    #panzoom-viewport {
        height: clamp(500px, 75vh, 900px);
    }
}

.dark #panzoom-viewport {
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        radial-gradient(circle, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
}

#panzoom-viewport:active {
    cursor: grabbing;
}

.dark .studio-mockup-viewer {
    background-color: rgba(24, 24, 27, 0.5);
    border-color: #27272a;
}

/* 6. Preview Controls (Light/Dark Mode and Zoom) */
.studio-preview-controls {
    position: absolute;
    top: 1.5rem;
    left: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 40;
}

.studio-platform-switcher {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #f4f4f5;
    border-radius: 16px;
    border: 1px solid #e4e4e7;
    margin-bottom: 24px;
}

.dark .studio-platform-switcher {
    background: #18181b;
    border-color: #27272a;
}

.studio-platform-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: #71717a;
    border: 1px solid #e4e4e7;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.dark .studio-platform-btn {
    background: #000;
    color: #a1a1aa;
    border-color: #27272a;
}

.studio-platform-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    color: #000;
}

.dark .studio-platform-btn:hover {
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.studio-platform-btn.active {
    background: #000;
    color: #fff;
    border-color: #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dark .studio-platform-btn.active {
    background: #fff;
    color: #000;
    border-color: #fff;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

.studio-platform-btn svg {
    width: 20px;
    height: 20px;
}

.studio-platform-btn::after {
    content: attr(data-label);
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0;
    transition: all 0.2s;
    pointer-events: none;
    color: #a1a1aa;
}

.studio-platform-btn:hover::after,
.studio-platform-btn.active::after {
    opacity: 1;
    bottom: -18px;
}

.studio-platform-btn.active::after {
    color: #000;
}

.dark .studio-platform-btn.active::after {
    color: #fff;
}

.studio-zoom-controls {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    gap: 0.5rem;
    z-index: 50;
}

.studio-zoom-btn {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.dark .studio-zoom-btn {
    background-color: #27272a;
    color: #ffffff;
}

.studio-zoom-btn:active {
    transform: scale(0.9);
}

.studio-reset-btn {
    padding: 0 0.75rem;
    height: 2.5rem;
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.625rem;
    font-weight: 900;
    text-transform: uppercase;
    transition: transform 0.2s;
}

.dark .studio-reset-btn {
    background-color: #27272a;
    color: #ffffff;
}

.studio-mode-switcher {
    display: flex;
    background-color: #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.25rem;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

.dark .studio-mode-switcher {
    background-color: #27272a;
}

.studio-mode-btn {
    padding: 0.25rem 1rem;
    font-size: 0.5625rem;
    font-weight: 900;
    border-radius: 0.5rem;
    transition: all 0.2s;
    opacity: 0.5;
    color: #6b7280;
}

.studio-mode-btn.active {
    background-color: #ffffff;
    color: #000000;
    opacity: 1;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.dark .studio-mode-btn.active {
    background-color: #3f3f46;
    color: #ffffff;
}

#ntf-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.ntf-item {
    background: white;
    padding: 16px 20px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 300px;
    transform: translateX(120%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
}

.dark .ntf-item {
    background: #18181b;
    color: white;
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.ntf-item.show {
    transform: translateX(0);
}

.ntf-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ntf-error .ntf-icon {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.ntf-success .ntf-icon {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.ntf-content {
    flex-grow: 1;
}

.ntf-title {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 2px;
}

.ntf-message {
    font-size: 13px;
    opacity: 0.7;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: white;
    width: 90%;
    max-width: 400px;
    padding: 32px;
    border-radius: 32px;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
}

.dark .modal-card {
    background: #18181b;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-overlay.show .modal-card {
    transform: translateY(0) scale(1);
}

.modal-icon {
    width: 64px;
    height: 64px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.modal-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 8px;
}

.modal-desc {
    font-size: 14px;
    opacity: 0.6;
    line-height: 1.5;
    margin-bottom: 28px;
}

.modal-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-modal {
    padding: 12px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s;
}

.btn-modal-cancel {
    background: #f4f4f5;
    color: #71717a;
}

.dark .btn-modal-cancel {
    background: #27272a;
    color: #a1a1aa;
}

.btn-modal-confirm {
    background: #ef4444;
    color: white;
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.2);
}

.btn-modal-confirm:hover {
    background: #dc2626;
    transform: translateY(-2px);
}


.studio-file-wrapper {
    position: relative;
    width: 100%;
}

.studio-file-label-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: rgba(244, 244, 245, 0.8);
    border: 2px dashed #d4d4d8;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #71717a;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark .studio-file-label-btn {
    background: rgba(24, 24, 27, 0.8);
    border-color: #3f3f46;
    color: #a1a1aa;
}

.studio-file-label-btn:hover {
    border-color: #1D9BF0;
    color: #1D9BF0;
    background: rgba(29, 155, 240, 0.05);
}

.studio-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.mockup-light {
    --ig-link-color: #00376b;
    --ig-btn-bg: #efefef;
    --ig-btn-text: #000000;
    --divider-color: #efefef;
    --text-main: #262626;
    --text-dim: #8e8e8e;
    --ig-follow-color: #0095f6;
}

.mockup-dark {
    --ig-link-color: #a3bcff;
    --ig-btn-bg: #262626;
    --ig-btn-text: #ffffff;
    --divider-color: #262626;
    --text-main: #f5f5f5;
    --text-dim: #a8a8a8;
    --ig-follow-color: #a3bcff;
}

.mockup-light,
.mockup-dark {
    transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: background-color, color;
}

.mockup-light {
    background-color: #ffffff !important;
    color: #000000 !important;
}

.mockup-dark {
    background-color: #000000 !important;
    color: #ffffff !important;
}

.mockup-light .text-main {
    color: #262626 !important;
}

.mockup-dark .text-main {
    color: #f5f5f5 !important;
}

.mockup-light .text-dim {
    color: #8e8e8e !important;
}

.mockup-dark .text-dim {
    color: #a8a8a8 !important;
}

.border-divider {
    border-color: var(--divider-color) !important;
}

.text-ig-link {
    color: var(--ig-link-color) !important;
}

/* IG Buttons */
.ig-btn-primary {
    background-color: #0095F6 !important;
    color: #ffffff !important;
    font-weight: 600;
    border-radius: 8px;
    height: 30.5px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    border: none;
    width: 100%;
}

.ig-btn-secondary {
    background-color: var(--ig-btn-bg) !important;
    color: var(--ig-btn-text) !important;
    font-weight: 600;
    border-radius: 8px;
    height: 30.5px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    border: none;
    width: 100%;
}

/* Story Rings - Unified Logic */
.story-ring {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    transition: background 0.3s ease, transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.story-ring::before {
    content: '';
    position: absolute;
    inset: 2.2px;
    border-radius: 50%;
    z-index: 1;
}

.mockup-light .story-ring::before {
    background: #ffffff !important;
}

.mockup-dark .story-ring::before {
    background: #000000 !important;
}

.story-ring.status-none::before {
    display: none;
}

.story-ring.status-public {
    background: linear-gradient(45deg, #f9ce34, #ee2a7b, #6228d7) !important;
}

.story-ring.status-private {
    background: #45bd62 !important;
}

.story-ring.status-none {
    background: transparent !important;
}

/* Canvas Base */
.ig-canvas {
    font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    background: white;
    padding: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.4s ease-out;
    transform-origin: top center;
    width: 100%;
}