:root {
    --bg-color: #f5f5f7;
    --editor-bg: white;
    --text-color: #1d1d1f;
    --border-color: #d2d2d7;
    --secondary-text: #86868b;
    --button-bg: #007AFF;
    --button-hover: #0051d5;
    --button-active: #003a9f;
    --shadow: rgba(0, 0, 0, 0.1);
    --phone-scale: 1; /* Default scale for the phone preview */
}

:root.dark-mode {
    --bg-color: #1c1c1e;
    --editor-bg: #2c2c2e;
    --text-color: #ffffff;
    --border-color: #3a3a3c;
    --secondary-text: #a1a1a6;
    --button-bg: #0a84ff;
    --button-hover: #0051d5;
    --button-active: #003a9f;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* Disable transitions during initial load */
.no-transition * {
    transition: none !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    transition: background-color 0.3s ease;
}

/* Editor wrapper for title and form */
.editor-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 270px;
    margin: 20px;
}

/* Title header above the form */
.title-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 15px;
    background-color: var(--editor-bg);
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.title-header h1 {
    font-size: 24px;
    color: var(--text-color);
    font-weight: 600;
    margin: 0;
    transition: color 0.3s ease;
}

.title-header .header-controls {
    display: flex;
    align-items: center;
}

.container {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
}

.editor-section {
    flex: 1;
    background-color: var(--editor-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px var(--shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.preview-section {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 15px;
}

h1 {
    font-size: 24px;
    margin: 0;
    color: var(--text-color);
    font-weight: 600;
    transition: color 0.3s ease;
}

.header-controls {
    display: flex;
    align-items: center;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
    transition: color 0.3s ease;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background-color: var(--editor-bg);
    color: var(--text-color);
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.upload-hint {
    font-size: 12px;
    color: var(--secondary-text);
    margin-top: 5px;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.custom-price-container,
.in-app-purchases-container,
.dark-mode-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-price-container label,
.in-app-purchases-container label,
.dark-mode-container label {
    margin: 0;
    font-weight: normal;
    line-height: 22px; /* Match the height of the toggle */
}

#custom-price {
    flex: 1;
    max-width: 100px;
    margin-left: 8px;
}

/* Form row styling */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-column {
    display: flex;
    flex-direction: column;
}

/* Adjust margins for better spacing */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Dark mode toggle in header */
.header-controls .dark-mode-container {
    font-size: 14px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}



/* Responsive adjustments for form rows */
@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* Drag and drop styles */
.drag-over {
    outline: 2px dashed #007AFF !important;
    background-color: rgba(0, 122, 255, 0.1);
}

/* Phone frame and App Store styling */
.phone-frame {
    width: calc(375px * var(--phone-scale));
    height: calc(812px * var(--phone-scale));
    background-color: white;
    /* Use super-ellipse for authentic iPhone shape */
    border-radius: calc(55px * var(--phone-scale)) / calc(60px * var(--phone-scale));
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    border: calc(10px * var(--phone-scale)) solid #1d1d1f;
    margin: calc(20px * var(--phone-scale));
    /* Prevent text selection in the preview */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Make phone frame lighter in dark mode */
.dark-mode .phone-frame {
    border-color: var(--editor-bg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Dynamic Island for modern iPhones */
.phone-frame::before {
    content: '';
    position: absolute;
    width: calc(120px * var(--phone-scale));
    height: calc(30px * var(--phone-scale));
    background-color: #1d1d1f;
    top: calc(10px * var(--phone-scale));
    left: 50%;
    transform: translateX(-50%);
    border-radius: calc(20px * var(--phone-scale));
    z-index: 2;
}

.dark-mode .phone-frame::before {
    background-color: var(--editor-bg);
}

.app-store-search {
    height: 100%;
    overflow-y: auto;
    background-color: #ffffff;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Dark mode toggle checkbox styling */
input[type="checkbox"] {
    appearance: none;
    width: 40px;
    height: 22px;
    background-color: var(--border-color);
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    background-color: white;
    transition: transform 0.3s ease;
}

input[type="checkbox"]:checked {
    background-color: var(--button-bg);
}

input[type="checkbox"]:checked::before {
    transform: translateX(18px);
}

/* Dark mode preview styles */
.dark-mode-preview .app-store-search {
    background-color: #000000;
}

/* App Header Styling - iOS 17-18 Design */
.app-header {
    background-color: white;
    padding: calc(16px * var(--phone-scale)) calc(18px * var(--phone-scale)) calc(6px * var(--phone-scale));
}

.dark-mode-preview .app-header {
    background-color: #000000;
}

.app-header-row-one {
    display: flex;
    align-items: center;
    margin-bottom: calc(12px * var(--phone-scale));
}

.app-header-row-two {
    display: grid;
    grid-template-columns: minmax(auto, 1fr) minmax(auto, 1fr) minmax(auto, 1fr);
    align-items: center;
    gap: calc(10px * var(--phone-scale));
    overflow: hidden;
}

.app-icon-container {
    width: calc(60px * var(--phone-scale));
    height: calc(60px * var(--phone-scale));
    margin-right: calc(10px * var(--phone-scale));
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
}

.app-icon-container::after {
    content: 'Click or Drag & Drop to upload';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    display: flex;
    align-items: center;
    text-align: center;
    font-size: calc(10px * var(--phone-scale));
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: calc(15px * var(--phone-scale));
}

.app-icon-container:hover::after {
    opacity: 1;
}

/* Disable hover effect for non-interactive elements */
.no-drop-zone:hover::after {
    opacity: 0 !important;
}

.app-icon {
    width: 100%;
    height: 100%;
    border-radius: calc(15px * var(--phone-scale));
    object-fit: cover;
    overflow-clip-margin: unset;
    border: calc(0.5px * var(--phone-scale)) solid rgba(0, 0, 0, 0.08);
}

.dark-mode-preview .app-icon {
    border: calc(0.5px * var(--phone-scale)) solid rgba(255, 255, 255, 0.15);
}

/* Placeholder styles for app icon */
.app-icon-placeholder {
    width: 100%;
    height: 100%;
    border-radius: calc(15px * var(--phone-scale));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #007AFF;
    color: white;
    text-align: center;
}

.dark-mode-preview .app-icon-placeholder {
    background-color: #0a84ff;
}

.app-icon-placeholder .placeholder-title {
    font-size: calc(10px * var(--phone-scale));
    font-weight: bold;
    margin-bottom: calc(4px * var(--phone-scale));
}

.app-icon-placeholder .placeholder-subtitle {
    font-size: calc(9px * var(--phone-scale));
}

.app-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.app-info h3 {
    font-size: calc(14px * var(--phone-scale));
    font-weight: 650;
    margin-bottom: calc(5px * var(--phone-scale));
    color: #1d1d1f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.dark-mode-preview .app-info h3 {
    color: #FFFFFF;
}

.app-info p {
    font-size: calc(11px * var(--phone-scale));
    color: #86868b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.dark-mode-preview .app-info p {
    color: #8D8C93;
}

.app-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 10px;
    flex-shrink: 0;
}

.app-button button {
    background-color: #EEEEEF;
    color: #007AFF;
    border: none;
    border-radius: calc(16px * var(--phone-scale));
    padding: calc(4px * var(--phone-scale)) calc(16px * var(--phone-scale));
    font-size: calc(13px * var(--phone-scale));
    font-weight: 700;
    cursor: pointer;
    letter-spacing: calc(-0.2px * var(--phone-scale));
}

.dark-mode-preview .app-button button {
    background-color: #1C1C1E;
    color: #0a84ff;
}

/* Style for in-app purchases span - use a class instead of ID */
.in-app-purchases-text {
    font-size: calc(8px * var(--phone-scale));
    color: #86868b;
    margin-top: calc(2px * var(--phone-scale));
    white-space: nowrap;
    display: none;
}

.app-rating {
    display: flex;
    align-items: center;
    gap: 3px;
    justify-content: flex-start;
    min-width: 0;
}

/* App reviews - use a class instead of ID */
.app-reviews-text {
    font-size: calc(11px * var(--phone-scale));
    font-weight: 500;
    letter-spacing: calc(-0.2px * var(--phone-scale));
    color: #C4C4C5;
    height: calc(12px * var(--phone-scale));
    line-height: calc(12px * var(--phone-scale));
    white-space: nowrap;
}

.dark-mode-preview .app-reviews-text {
    color: #8E8D94;
}

.stars {
    display: flex;
    font-size: calc(10px * var(--phone-scale));
    flex-shrink: 0;
}

.star {
    position: relative;
    display: inline-block;
    line-height: calc(12px * var(--phone-scale));
}

.star.filled {
    color: #8E8E91;
}

.dark-mode-preview .star.filled {
    color: #8E8D94;
}

.star.partial {
    position: relative;
    display: inline-block;
    color: #8E8E91;
}

.dark-mode-preview .star.partial {
    color: #8E8D94;
}

.star.partial::before {
    content: '★';
    position: absolute;
    left: 0;
    top: 0;
    color: #8E8E91;
    overflow: hidden;
    width: var(--fill-percentage);
}

.dark-mode-preview .star.partial::before {
    color: #8E8D94;
}

.star.empty {
    color: #8E8E91;
}

.dark-mode-preview .star.empty {
    color: #8E8D94;
}

.app-developer {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

.app-category {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    overflow: hidden;
}

/* Developer name and category - use classes instead of IDs */
.developer-name-text,
.category-name-text {
    font-size: calc(11px * var(--phone-scale));
    font-weight: 500;
    letter-spacing: calc(-0.2px * var(--phone-scale));
    color: #C4C4C5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.dark-mode-preview .developer-name-text,
.dark-mode-preview .category-name-text {
    color: #8E8D94;
}

/* Screenshots Styling */
.app-screenshots-section {
    padding: 0 calc(16px * var(--phone-scale));
    width: 100%;
}

.screenshot-scroll {
    display: flex;
    justify-content: space-between;
    padding: calc(5px * var(--phone-scale)) 0 calc(15px * var(--phone-scale));
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    gap: calc(5px * var(--phone-scale)); /* Small gap between screenshots */
    width: 100%;
}

.screenshot-scroll::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

.screenshot-container {
    flex: 1;
    width: calc((100% - 16px) / 3); /* Divide available width by 3 with gaps */
    /* Height is 2.15 times the width as specified */
    aspect-ratio: 1 / 2.15;
    border-radius: calc(14px * var(--phone-scale)); /* Exact corner radius as specified */
    overflow: hidden;
    border: calc(0.5px * var(--phone-scale)) solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    position: relative;
}

.screenshot-container::after {
    content: 'Click or Drag & Drop to upload';
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(12px * var(--phone-scale));
    opacity: 0;
    transition: opacity 0.2s;
}

.screenshot-container:hover::after {
    opacity: 1;
}

.app-screenshot {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Prevent pixaled images from stretching */
    overflow-clip-margin: unset;
}

/* Placeholder styles for app screenshots */
.screenshot-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #f0f0f0, #e5e5e5);
    color: #8e8e93;
    text-align: center;
}

.dark-mode-preview .screenshot-placeholder {
    background: linear-gradient(to bottom, #2c2c2e, #1c1c1e);
    color: #8e8e93;
}

.screenshot-placeholder .placeholder-title {
    font-size: calc(11px * var(--phone-scale));
    font-weight: bold;
    margin-bottom: calc(4px * var(--phone-scale));
}

.screenshot-placeholder .placeholder-subtitle {
    font-size: calc(10px * var(--phone-scale));
}

/* App Store Navigation and Status Bar */
.app-store-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: transparent;

    /* Workaround image being above everything and thus not being corner-cropped, because of the absolute position. Only happening on iOS 16 and below. */
    overflow: hidden;
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
}

.bottom-bar-image {
    width: 100%;
    display: block;
}

.app-store-status-bar {
    width: 100%;
    position: relative;
}

.status-bar-image {
    width: 100%;
    display: block;
}

/* Action buttons styling */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.action-button {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-button svg {
    width: 16px;
    height: 16px;
}

.action-button.primary {
    background-color: var(--button-bg);
    color: white;
}

.action-button.primary:hover {
    background-color: var(--button-hover);
}

.action-button.primary:active {
    background-color: var(--button-active);
}

.action-button.secondary {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.action-button.secondary:hover {
    background-color: var(--border-color);
}

.action-button.secondary:active {
    background-color: var(--secondary-text);
    color: white;
}

/* Add some subtle improvements */
.form-group label {
    font-size: 14px;
    font-weight: 500;
}

/* Better focus states */
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--button-bg);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Smoother transitions */
input[type="text"],
input[type="number"],
select {
    transition: all 0.2s ease;
}

/* Developer Spotlight Section */
.developer-spotlight {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.spotlight-header {
    margin-bottom: 15px;
}

.spotlight-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    transition: color 0.3s ease;
}

.spotlight-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.spotlight-content:hover {
    border-color: var(--button-bg);
    box-shadow: 0 2px 12px rgba(0, 122, 255, 0.1);
}

.spotlight-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px var(--shadow);
}

.spotlight-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.spotlight-info {
    flex: 1;
    min-width: 0;
}

.spotlight-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

.spotlight-subtitle {
    font-size: 12px;
    color: var(--secondary-text);
    line-height: 1.3;
    margin-bottom: 6px;
    transition: color 0.3s ease;
}

.spotlight-platform {
    display: flex;
    align-items: center;
}

.platform-badge {
    font-size: 10px;
    font-weight: 500;
    color: var(--secondary-text);
    background-color: var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.spotlight-action {
    flex-shrink: 0;
}

.spotlight-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background-color: var(--button-bg);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.spotlight-button:hover {
    background-color: var(--button-hover);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.spotlight-button:active {
    background-color: var(--button-active);
    transform: translateY(0);
}

/* Scrollable content area */
.scrollable-content {
    height: calc(650px * var(--phone-scale));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS devices */
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    padding-bottom: calc(30px * var(--phone-scale)); /* Add space at the bottom of the scroll view */
}

.scrollable-content::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari and Edge */
}

/* Footer styling */
.footer {
    width: calc(100% - 40px);
    text-align: center;
    padding: 18px 20px;
    margin: 30px 20px 30px 20px;
    font-size: 13px;
    color: var(--secondary-text);
    transition: color 0.3s ease, border-color 0.3s ease;
    background-color: var(--editor-bg);
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow);
}

.footer p {
    margin: 5px 0;
}

.footer a {
    color: var(--button-bg);
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
    color: var(--button-hover);
}

/* Featured item styling */
.app-featured-item {
    width: 100%;
    margin-bottom: 5px; /* Space between user app and featured app */
    position: relative;
}

/* Prevent drag/drop interaction on featured app */
.no-drop-zone::after {
    display: none !important; /* Hide the "Click to upload" message on non-interactive items */
}

.no-drop-zone {
    cursor: default !important;
}

/* Style the GET button to indicate it's clickable */
.featured-app-item .app-button button {
    cursor: pointer !important;
}

/* Add explicit cursor pointer to make the button more obviously clickable */
.featured-app-item .app-button button,
.featured-app-item .app-header {
    cursor: pointer !important;
}

/* Responsive adjustments for small screens */
/* Progressive scaling for different device sizes */
@media (max-width: 414px) {
    :root {
        --phone-scale: 0.9;
    }
    
    /* Ensure dark mode toggle remains functional on small screens */
    .editor-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 375px) {
    :root {
        --phone-scale: 0.8;
    }
}

@media (max-width: 320px) {
    :root {
        --phone-scale: 0.7;
    }
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .preview-section {
        margin-top: 30px;
    }

    .footer {
        margin: 25px 20px 30px 20px;
        width: calc(100% - 40px);
    }

    /* Responsive spotlight adjustments */
    .spotlight-content {
        gap: 12px;
        padding: 14px;
    }

    .spotlight-button {
        padding: 6px 8px;
        font-size: 11px;
        width: 32px;
        height: 32px;
        text-indent: -9999px;
        position: relative;
    }

    .spotlight-button::after {
        content: "↗";
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        text-indent: 0;
        font-size: 14px;
        font-weight: 600;
        line-height: 1;
    }
}