/* --- Global Styles & Variables --- */
:root {
    --primary-color: #00ff78;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #ffffff;
    --text-muted-color: #aaaaaa;
    --border-color: #333333;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}
a { color: var(--primary-color); text-decoration: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.loading-spinner {
    border: 5px solid var(--surface-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 50px auto;
}
.full-page-loader {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--background-color); z-index: 9999;
    display: flex; justify-content: center; align-items: center;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Top Bar / Header --- */
.top-bar {
    background-color: var(--surface-color); padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 1000;
}
.top-bar .container { display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.8rem; font-weight: 700; color: var(--primary-color); }
.main-nav { display: flex; align-items: center; gap: 1rem; }
.search-container { position: relative; display: flex; align-items: center; }
.search-icon-btn {
    background: none; border: none; color: var(--text-muted-color);
    cursor: pointer; padding: 0.5rem; display: flex;
}
.search-icon-btn:hover { color: var(--primary-color); }
.search-input {
    width: 0; padding: 0.7rem 0; border: none;
    border-bottom: 2px solid var(--primary-color);
    background: transparent; color: var(--text-color);
    font-size: 1rem; opacity: 0;
    transition: width 0.4s ease-in-out, opacity 0.4s ease-in-out, padding 0.4s ease-in-out;
    position: absolute; right: 100%;
}
.search-container.active .search-input {
    width: 250px; opacity: 1; padding-left: 1rem; padding-right: 1rem;
}
.auth-buttons { display: flex; align-items: center; }
#user-info { display: none; align-items: center; gap: 15px; }
#user-info img { width: 40px; height: 40px; border-radius: 50%; }

/* --- Main Content & App Grid --- */
main { padding: 2rem 0; }
main section { margin-bottom: 3rem; }
.section-title {
    font-size: 2rem; margin-bottom: 1.5rem; color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem; display: inline-block;
}
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem;
}
.app-card {
    background-color: transparent;
    transition: transform 0.3s;
    display: flex; flex-direction: column; text-align: center;
}
.app-card:hover { transform: translateY(-5px); }
.app-card .app-icon {
    width: 100%;
    padding-top: 100%;
    position: relative;
    background-color: var(--surface-color);
    border-radius: 24%; /* Squircle shape */
    overflow: hidden;
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.app-card .app-icon img {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; object-fit: cover;
}
.app-card-info { padding: 0 0.25rem; }
.app-card-title {
    font-size: 1rem; font-weight: 600; color: var(--text-color);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-card-downloads {
    font-size: 0.8rem; color: var(--text-muted-color);
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.app-card-downloads svg { width: 12px; height: 12px; }

/* --- App Detail Page --- */
.app-detail-header { display: flex; align-items: center; gap: 2rem; margin-bottom: 2rem; }
.app-detail-icon {
    width: 150px; height: 150px;
    border-radius: 22%; object-fit: cover;
    flex-shrink: 0;
}
.app-detail-info-wrapper { display: flex; flex-direction: column; }
.app-detail-info-wrapper h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.app-meta { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted-color); margin-bottom: 1rem; }
.meta-separator { color: var(--border-color); }
.download-btn {
    display: inline-block; background-color: var(--primary-color);
    color: var(--background-color); padding: 0.8rem 2.5rem; font-size: 1.2rem;
    font-weight: 700; border-radius: 8px; text-align: center; transition: background-color 0.3s;
    align-self: flex-start;
}
.download-btn:hover { background-color: #00e66b; }
.screenshots-gallery {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem; margin: 2rem 0;
}
.screenshots-gallery img { width: 100%; border-radius: 8px; border: 1px solid var(--border-color); }
.app-description { background: var(--surface-color); padding: 1.5rem; border-radius: 8px; }
.app-description p { white-space: pre-wrap; }

/* --- Footer --- */
.site-footer {
    background-color: var(--surface-color); color: var(--text-muted-color);
    padding: 2rem 0; margin-top: 3rem; border-top: 1px solid var(--border-color);
}
.footer-bottom { text-align: center; }

/* --- Admin & Login Page --- */
.form-container { max-width: 700px; margin: 2rem auto; padding: 2rem; background-color: var(--surface-color); border-radius: 8px; }
.form-container h1.logo { font-size: 2.5rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 0.8rem; background-color: var(--background-color);
    border: 1px solid var(--border-color); border-radius: 5px;
    color: var(--text-color); font-size: 1rem;
}
.form-group textarea { min-height: 150px; resize: vertical; }
.btn-submit {
    width: 100%; padding: 1rem; font-size: 1.2rem; font-weight: 700;
    background-color: var(--primary-color); color: var(--background-color);
    border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s;
}
.btn-submit:hover { background-color: #00e66b; }
.btn-submit:disabled { background-color: #555; cursor: not-allowed; }
#upload-status { text-align: center; margin-top: 1rem; font-weight: 600; }

/* --- Admin Management List --- */
.manage-apps-container { margin-top: 4rem; }
.manage-app-item {
    background-color: var(--surface-color); border-radius: 8px; padding: 1rem;
    margin-bottom: 1rem; display: flex; align-items: center; gap: 1rem;
    border: 1px solid var(--border-color);
}
.manage-app-icon { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; }
.manage-app-info { flex-grow: 1; }
.manage-app-title { font-weight: 600; font-size: 1.1rem; color: var(--text-color); }
.manage-app-category { font-size: 0.9rem; color: var(--text-muted-color); }
.manage-app-actions button {
    padding: 0.5rem 1rem; border: none; border-radius: 5px; cursor: pointer;
    font-weight: 600; transition: background-color 0.3s;
}
.manage-app-actions .btn-edit { background-color: #3a76f8; color: white; margin-right: 0.5rem; }
.manage-app-actions .btn-delete { background-color: #f83a3a; color: white; }
.btn-cancel {
    display: none; width: 100%; margin-top: 0.5rem; padding: 0.8rem;
    font-size: 1rem; font-weight: 600; background-color: #6c757d;
    color: white; border: none; border-radius: 5px; cursor: pointer;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    .top-bar .container { flex-wrap: wrap; }
    .search-container.active .search-input { width: 150px; }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 1rem; }
    .app-detail-header { flex-direction: column; text-align: center; }
    .app-detail-info-wrapper { align-items: center; }
    .download-btn { align-self: center; }
}