/* ==========================================================================
   TWIBBON YPINH GENERATOR STYLESHEET (SHADCN MONOCHROME EDITION)
   Warna Aksen Brand: #009946 (Green) & #E10717 (Red)
   Theme: Shadcn UI zinc monochrome (default light/dark)
   ========================================================================== */

/* CSS Variables */
:root {
    /* Brand Colors */
    --brand-green: #009946;
    --brand-green-hover: #007d39;
    --brand-green-rgb: 0, 153, 70;
    --brand-red: #E10717;
    --brand-red-hover: #be0512;
    --brand-red-rgb: 225, 7, 23;

    /* Light Theme (Default Shadcn Zinc) */
    --background: #fafafa;
    --foreground: #09090b;

    --card: #ffffff;
    --card-foreground: #09090b;

    --muted: #f4f4f5;
    --muted-foreground: #71717a;
    --accent-muted: #e4e4e7;

    --border: #e4e4e7;
    --input: #e4e4e7;
    --ring: rgba(0, 153, 70, 0.4);

    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(228, 228, 231, 0.7);
    --glass-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.02), 0 1px 2px -1px rgba(0, 0, 0, 0.02);

    /* Viewport Workspace Dot Grid */
    --workspace-bg: #f4f4f5;
    --workspace-dots: #e4e4e7;

    /* UI Specs */
    --radius: 0.5rem; /* Shadcn default */
    --radius-lg: 0.75rem;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-medium: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

/* Dark Theme Variables (Pure Monochrome / Zinc with Brand Accent) */
body.dark-theme {
    --background: #09090b; /* zinc-950 */
    --foreground: #fafafa; /* zinc-50 */

    --card: #09090b; /* zinc-950 background card */
    --card-foreground: #fafafa;

    --muted: #18181b; /* zinc-900 */
    --muted-foreground: #a1a1aa; /* zinc-400 */
    --accent-muted: #27272a; /* zinc-800 */

    --border: #27272a; /* zinc-800 border */
    --input: #27272a;
    --ring: rgba(0, 153, 70, 0.6);

    --glass-bg: rgba(9, 9, 11, 0.9);
    --glass-border: rgba(39, 39, 42, 0.8);
    --glass-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.5);

    /* Viewport Workspace Dot Grid */
    --workspace-bg: #09090b; /* zinc-950 */
    --workspace-dots: #27272a; /* zinc-800 */

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.875rem; /* Shadcn default 14px */
    line-height: 1.5;
    color: var(--foreground);
    background-color: var(--background);
    min-height: 100vh;
    transition: background-color var(--transition-medium), color var(--transition-medium);
    overflow-x: hidden;
}

/* Subtle Gradient Glow in Dark Mode */
body.dark-theme::before {
    content: '';
    position: fixed;
    top: 0;
    left: 25%;
    width: 50vw;
    height: 50vh;
    background: radial-gradient(circle, rgba(0, 153, 70, 0.04) 0%, rgba(0, 153, 70, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 65px);
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Sticky Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(var(--background) == #fafafa ? 250, 250, 250 : 9, 9, 11, 0.8);
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background-color var(--transition-medium), border-color var(--transition-medium);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    gap: 1rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--foreground);
}

.logo-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.logo-img {
    height: 36px;
    width: auto;
    display: block;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-actions-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.theme-toggle-btn:hover {
    background: var(--muted);
    border-color: var(--muted-foreground);
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0 0.75rem;
    height: 34px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
    text-decoration: none;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: var(--foreground);
    background: var(--muted);
}

/* Main Grid */
.main {
    flex: 1;
    margin-top: 1.5rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr 340px;
    }
}

@media (min-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr 380px;
    }
}

/* Shadcn Style Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
}

.card-title svg {
    color: var(--brand-green);
    stroke-width: 2.2px;
}

.card-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Figma/Canva Dotted Editor Viewport */
.canvas-section {
    position: sticky;
    top: 80px;
    z-index: 30;
}

.canvas-card {
    width: 100%;
    padding: 2.5rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--workspace-bg);
    background-image: radial-gradient(var(--workspace-dots) 1px, transparent 1px);
    background-size: 16px 16px;
    background-position: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-height: 480px;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.02);
}

/* Canvas Wrapper - Floating Frame */
.canvas-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: transparent; /* Fix dynamic aspect ratio gaps */
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04), 0 0 0 1px var(--border);
    cursor: move;
    transition: aspect-ratio var(--transition-medium), max-width var(--transition-medium);
}

.canvas-wrapper.is-feed {
    aspect-ratio: 4 / 5;
    max-width: 380px;
}

.canvas-wrapper.is-story {
    aspect-ratio: 9 / 16;
    max-width: 280px;
}

@media (min-width: 768px) {
    .canvas-wrapper.is-feed {
        max-width: 450px;
    }
    .canvas-wrapper.is-story {
        max-width: 310px;
    }
}

@media (min-width: 1024px) {
    .canvas-wrapper.is-feed {
        max-width: 520px;
    }
    .canvas-wrapper.is-story {
        max-width: 350px;
    }
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* Upload Dotted Overlay inside Canvas */
.canvas-upload-overlay {
    position: absolute;
    inset: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    cursor: pointer;
    transition: all var(--transition-medium);
    z-index: 10;
    border: 1.5px dashed var(--border);
    border-radius: calc(var(--radius) - 2px);
}

.canvas-upload-overlay:hover {
    background: var(--muted);
    border-color: var(--brand-green);
}

.canvas-upload-overlay:hover .upload-icon {
    transform: translateY(-2px);
    color: var(--brand-green);
    background: rgba(0, 153, 70, 0.1);
}

.canvas-upload-overlay.dragover {
    background: rgba(0, 153, 70, 0.05);
    border-color: var(--brand-green);
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    padding: 1.25rem;
}

.upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--muted);
    border-radius: 50%;
    color: var(--muted-foreground);
    border: 1px solid var(--border);
    transition: all var(--transition-medium);
}

.upload-text {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -0.01em;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    max-width: 180px;
    line-height: 1.4;
}

/* Floating Delete Photo Button (Shadcn style) */
.btn-delete-photo {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--card);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius);
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow);
}

.btn-delete-photo:hover {
    background: var(--brand-red);
    border-color: var(--brand-red);
    color: #ffffff;
    transform: scale(1.05);
}

/* Controls Column */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-input {
    display: none;
}

/* Segmented Control Switcher (Shadcn Style) */
.template-switcher-card .card-content {
    padding: 0.75rem;
}

.template-options-grid {
    display: flex;
    flex-direction: row;
    background: var(--muted);
    border-radius: var(--radius);
    padding: 0.25rem;
    gap: 0.25rem;
}

.template-option-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    text-align: center;
    color: var(--muted-foreground);
    transition: all var(--transition-fast);
}

.template-option-btn:hover {
    color: var(--foreground);
}

.template-option-btn.active {
    background: var(--card);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
}

.template-icon-ratio {
    display: none; /* Simplify UI for Shadcn look */
}

.template-name {
    font-size: 0.8125rem;
    font-weight: 600;
}

.template-dims {
    font-size: 0.6875rem;
    opacity: 0.8;
    margin-top: 0.125rem;
}

/* Tab Navigation Triggers */
.tabs-list {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--muted);
    padding: 0.25rem;
    border-radius: var(--radius);
    height: 2.25rem;
}

.tab-trigger {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    height: 100%;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
    background-color: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-trigger:hover {
    color: var(--foreground);
}

.tab-trigger.active {
    color: var(--foreground);
    background-color: var(--card);
    box-shadow: var(--shadow-sm);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn var(--transition-fast) ease;
}

/* Desktop: Stacked layout for control panels */
@media (min-width: 768px) {
    .tabs-list {
        display: none;
    }

    .tab-panel {
        display: block !important;
        margin-bottom: 0.75rem;
    }
}

/* Sliders & Inputs (Shadcn Look) */
.text-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.8125rem;
    background-color: var(--card);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.text-input:focus {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 2px var(--ring);
}

textarea.text-input {
    resize: vertical;
    min-height: 76px;
    max-height: 120px;
    line-height: 1.4;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.control-label-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-label-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.control-value-badge {
    font-size: 0.75rem;
    font-weight: 600;
    font-family: monospace;
    color: var(--foreground);
}

/* Shadcn Style Custom Range Slider */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--accent-muted);
    border-radius: 999px;
    cursor: pointer;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--card);
    border: 1px solid var(--input);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

body.dark-theme .slider::-webkit-slider-thumb {
    background: #ffffff;
    border-color: #ffffff;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    border-color: var(--muted-foreground);
}

.slider::-webkit-slider-thumb:active {
    cursor: grabbing;
}

.slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--card);
    border: 1px solid var(--input);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-sm);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    margin-top: 0.125rem;
}

.rotation-control-flex {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.rotation-control-flex .slider {
    flex: 1;
}

/* Reset / Small Buttons */
.btn-reset-small {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-reset-small:hover {
    background: var(--muted);
    border-color: var(--muted-foreground);
    color: var(--foreground);
}

/* Buttons (Shadcn UI Specifications) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.8125rem; /* 13px */
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    height: 36px;
    padding: 0 1rem;
    border: 1px solid transparent;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-lg {
    height: 40px;
    padding: 0 1.25rem;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--brand-green);
    color: #ffffff;
    border-color: var(--brand-green);
}

.btn-primary:hover {
    background: var(--brand-green-hover);
    border-color: var(--brand-green-hover);
}

.btn-outline {
    background: transparent;
    color: var(--foreground);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--muted);
    border-color: var(--muted-foreground);
}

.btn-xs {
    height: 24px;
    padding: 0 0.375rem;
    font-size: 0.6875rem;
}

.btn-sm {
    height: 30px;
    padding: 0 0.75rem;
    font-size: 0.75rem;
}

/* Toggle Switch Indicator (Shadcn style) */
.btn-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 0.125rem 0.5rem 0.125rem 0.375rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--muted-foreground);
    transition: all var(--transition-fast);
}

.toggle-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted-foreground);
    transition: all var(--transition-fast);
}

.btn-toggle:hover {
    border-color: var(--muted-foreground);
}

.btn-toggle.active {
    background: var(--accent-muted);
    color: var(--foreground);
    border-color: var(--muted-foreground);
}

.btn-toggle.active .toggle-indicator {
    background: var(--brand-green);
    box-shadow: 0 0 6px var(--brand-green);
}

/* Mosaic Panel Controls */
.mosaic-controls {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity var(--transition-medium);
}

.mosaic-controls.active {
    opacity: 1;
    pointer-events: auto;
}

.mosaic-actions {
    display: flex;
    margin-top: 0.25rem;
}

.mosaic-actions .btn {
    width: 100%;
}

.mosaic-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
    padding: 0.625rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted-foreground);
    line-height: 1.35;
    text-align: left !important;
    font-size: 0.75rem;
}

.mosaic-hint svg {
    flex-shrink: 0;
    color: var(--brand-green);
    margin-top: 2px;
}

/* Canvas Mode cursor */
.canvas-wrapper.mosaic-mode {
    cursor: crosshair;
}

/* Download Area */
.action-buttons-wrapper {
    margin-top: 0.25rem;
}

.action-buttons-wrapper .btn-primary {
    width: 100%;
    font-weight: 600;
}

/* Hints & Typo helper */
.hint {
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    text-align: center;
    line-height: 1.35;
}

/* Footer (Shadcn style) */
.footer {
    margin-top: 3.5rem;
    padding: 1.5rem 0;
    text-align: center;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.footer p {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.footer .credit {
    font-weight: 500;
    color: var(--foreground);
}

.footer a.credit-link {
    color: var(--brand-green);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.footer a.credit-link:hover {
    color: var(--brand-green-hover);
    text-decoration: underline;
}

/* Toast System (Shadcn UI Toast) */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem; /* Floating bottom right like Shadcn */
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(50px);
    transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 767px) {
    .toast {
        right: 50%;
        transform: translateX(50%) translateY(50px);
    }
    .toast.show {
        transform: translateX(50%) translateY(0) !important;
    }

    /* Nonaktifkan sticky canvas di mobile agar input terlihat saat mengetik */
    .canvas-section {
        position: relative;
        top: 0;
        z-index: 10;
    }

    .canvas-card {
        min-height: auto;
        padding: 1.5rem 1rem;
    }

    /* Kurangi space atas di mobile */
    .app-container {
        padding: 1rem;
    }
    .main {
        margin-top: 0.75rem;
    }
    .header-container {
        padding: 0.5rem 1rem;
    }
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foreground);
}

.toast-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.toast-icon-wrapper.success {
    color: var(--brand-green);
}

.toast-icon-wrapper.error {
    color: var(--brand-red);
}

/* Selection */
::selection {
    background: rgba(var(--brand-green-rgb), 0.15);
}

/* Focus outline style */
*:focus-visible {
    outline: 2px solid var(--foreground);
    outline-offset: 2px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Helper Classes */
.hidden {
    display: none !important;
}

