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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header h1 {
    font-size: 24px;
}

.appicon img {
    pointer-events: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.username {
    font-size: 14px;
    opacity: 0.9;
}

.auth-btn, a.auth-btn {
    background: rgba(255,255,255,0.2) !important;
    border: 1px solid rgba(255,255,255,0.3);
    color: white !important;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    text-decoration: none;
    display: inline-block;
}

.auth-btn:hover, a.auth-btn:hover {
    background: rgba(255,255,255,0.3) !important;
    color: white !important;
}

/* Launchpad Container */
.appspace-container {
    position: fixed;
    top: 180px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    touch-action: none;
    transition: opacity 0.3s, filter 0.3s;
}

.appspace-container.folder-open {
    opacity: 0.3;
    filter: blur(10px);
    pointer-events: none;
}

.appspace-viewport {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    z-index: 3000;
}

.appspace-screens {
    display: flex;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    will-change: transform;
}

.appspace-screens.dragging {
    transition: none;
}

.appspace-screen {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0px;
}

.regions-container {
    display: grid;
    gap: 0;
    justify-content: left;
    align-items: left;
    /* justify-content: center;
    align-items: center; */
}

.region {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: var(--icon-gap-vertical) var(--icon-gap-horizontal);
}

.icon-slot {
    width: var(--icon-size);
    height: calc(var(--icon-size) + 20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    overflow: visible;
}

.icon-title {
    margin-top: 6px;
    font-size: 13px;
    color: #ffffff;
    text-align: center;
    max-width: var(--title-max-width);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 2px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.appicon {
    width: var(--icon-size);
    height: var(--icon-size);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s;
    border-radius: 0;
}

.appicon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: drop-shadow: (0 2px 8px rgba(0,0,0,0.15));
}

.appicon.folder {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    border-radius: 20%;
}
.appicon.folder img {
    width: 25%;
    height: 25%;
    flex-basis: 35%;
    display: flex;
    text-align: center;
    justify-content: center;
    align-items: center;
    margin-left: 9%;
    margin-top: 4%;
    margin-bottom: 4%;
}

.appicon.dragging {
    opacity: 0.7;
    transform: scale(1.1);
    z-index: 1000;
    position: fixed;
    pointer-events: none;
}

.appicon.drag-over {
    transform: scale(1.2);
}
.appicon.drag-over img {
    filter: drop-shadow(0 4px 16px rgba(74, 144, 226, 0.5));
}

.icon-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff3b30;
    color: white;
    border-radius: 16px;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    padding: 0 8px;
    border: 2px solid #f5f7fa;
}

.icon-slot.drag-placeholder {
    opacity: 0.3;
}

.folder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.folder-overlay.open {
    display: flex;
}

.folder-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 95%;
    max-height: 95%;
}

.folder-title {
    font-size: 22px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    cursor: text;
    padding: 8px 20px;
    border-radius: 8px;
    min-width: 150px;
    text-align: center;
    white-space: nowrap;
    margin-bottom: 12px;
}

.folder-title:hover {
    background: rgba(255,255,255,0.1);
}

.folder-title.editing {
    background: white;
    color: #333;
    text-shadow: none;
    border: 2px solid #4a90e2;
    outline: none;
}

.folder-container {
    background: rgba(255,255,255,0.25);
    border-radius: 20px;
    padding: 0px 30px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.folder-content {
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
}

.folder-screens {
    display: flex;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    will-change: transform;
}

.folder-screens.dragging {
    transition: none;
}

.folder-screen {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 40px 0;
}

/* Page Indicators */
.page-indicators {
    display: flex;
    gap: 8px;
    z-index: 50;
    justify-content: center;
    margin-top: 20px;
}

.appspace-viewport > .page-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
}

/* Folder page indicators - overlap content instead of adding space */
.folder-container > .page-indicators {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    z-index: 60;
}

.page-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    cursor: pointer;
    transition: all 0.3s;
}

.page-indicator.active {
    background: rgba(255,255,255,0.9);
    transform: scale(1.3);
}

.folder-container .page-indicator {
    background: rgba(255,255,255,0.4);
}

.folder-container .page-indicator.active {
    background: rgba(255,255,255,0.9); /* #4a90e2; */
}

.folder-container .icon-title {
    /* color: #333333; */
    text-shadow: none;
}

/* Scroll Zones */
.scroll-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50px;
    z-index: 90;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.scroll-zone.left {
    left: 0;
}

.scroll-zone.right {
    right: 0;
}

.scroll-zone.active {
    pointer-events: all;
    opacity: 1;
    background: rgba(74, 144, 226, 0.2);
}

/* Folder scroll zones - positioned on folder-container, flush with edges, clipped by border-radius */
.folder-container .scroll-zone {
    top: 0;
    bottom: 0;
}

.folder-container .scroll-zone.left {
    left: 0;
    border-radius: 20px 0 0 20px;
}

.folder-container .scroll-zone.right {
    right: 0;
    border-radius: 0 20px 20px 0;
}

/* Edit Modal */
.edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.edit-modal.open {
    display: flex;
}

.edit-modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.edit-modal h3 {
    margin-bottom: 20px;
    color: #333;
}

.edit-modal input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 15px;
}

.edit-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.edit-modal button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    font-weight: 500;
}

.edit-modal .btn-cancel {
    background: #e0e0e0;
    color: #333;
}

.edit-modal .btn-cancel:hover {
    background: #d0d0d0;
}

.edit-modal .btn-save {
    background: #4a90e2;
    color: white;
}

.edit-modal .btn-save:hover {
    background: #357abd;
}

.edit-modal .btn-delete {
    background: #ff3b30;
    color: white;
    margin-right: auto;
}

.edit-modal .btn-delete:hover {
    background: #e02b20;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

.checkbox-group label {
    cursor: pointer;
    user-select: none;
}

/* Insert Indicator */
.insert-indicator {
    position: absolute;
    background: rgba(74, 144, 226, 0.6);
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    z-index: 50;
}

.insert-indicator.visible {
    opacity: 0.8;
}

.drop-preview {
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    z-index: 45;
}

.drop-preview.visible {
    opacity: 1;
}

@media (max-width: 768px) {
    .header-content {
        gap: 10px;
    }
    
    .header-title {
        gap: 8px;
    }
    
    .header {
         padding: 3px 30px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .user-info {
        gap: 8px;
        font-size: 13px;
    }
    
    .username {
        font-size: 13px;
    }
    
    .auth-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Mobile nav is at bottom, so appspace starts right below header */
    .appspace-container {
        top: 56px;
        bottom: 74px; /* Leave room for bottom nav bar */
    }

    .appspace-screen {
        padding: 0px;
    }

    /* Page indicators need to be above the bottom nav bar */
    .appspace-viewport > .page-indicators {
        bottom: 10px; /* Above the bottom nav bar which is ~60px */
    }

    .folder-container > .page-indicators {
        bottom: 13px;
    }

    .folder-container {
        padding: 0px 30px;
    }
    
    .icon-title {
        font-size: 11px;
    }

    .folder-title {
        font-size: 18px;
    }
    
   .icon-badge {
       top: -6px;
       right: -6px;
       border-radius: 12px;
       min-width: 24px;
       height: 24px;
       font-size: 14px;
       padding: 0 6px;
       border: 2px solid #f5f7fa;
   }

}
