/* Base Styles & Variables */
:root {
    --primary-color: #d4af37; /* Gold */
    --secondary-color: #1a472a; /* Dark Green */
    --accent-color: #8b0000; /* Dark Red */
    --background-light: #f5f2e9;
    --background-dark: #2c2c2c;
    --text-color: #333;
    --text-light: #f5f2e9;
    --card-bg: rgba(255, 255, 255, 0.9);
    --transition: all 0.3s ease;
}

/* Rolling security banner */
.rolling-banner {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(26, 71, 42, 0.95); /* secondary color with opacity */
    color: var(--text-light);
    overflow: hidden;
    white-space: nowrap;
    border-top: 2px solid var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.banner-track {
    display: inline-block;
    padding: 0.5rem 0;
    animation: marquee 22s linear infinite;
}

.banner-item {
    display: inline-block;
    margin-right: 2.5rem;
    font-size: 0.95rem;
}

.rolling-banner:hover .banner-track {
    animation-play-state: paused;
}

@keyframes marquee {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

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

body {
    font-family: 'Noto Sans', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-light);
    background-image: url('../images/egyptian-pattern.png');
    background-attachment: fixed;
    background-size: cover;
    background-blend-mode: overlay;
}

/* Header Styles */
.marketplace-header {
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), 
                url('../images/egyptian-header.jpg') center/cover no-repeat;
    color: var(--text-light);
    text-align: center;
    padding: 4rem 1rem;
    position: relative;
    overflow: hidden;
}

.marketplace-header::before {
    content: '';
    position: absolute;
    bottom: -50px;
    left: 0;
    right: 0;
    height: 100px;
    /* pyramid-silhouette.png removed per request; use subtle decorative gradient instead */
    background: linear-gradient(180deg, rgba(26,71,42,0.0), rgba(26,71,42,0.12));
    opacity: 0.95;
}

.header-content h1 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 3rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.header-content p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.crm-link {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.85rem 1.75rem;
    background: var(--primary-color);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.125rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    transition: var(--transition);
    border: none;
}

.crm-link:hover {
    background: var(--secondary-color);
    color: var(--text-light);
}

/* Make CRM CTA more prominent on small screens */
@media (max-width: 600px) {
    .crm-cta .crm-link {
        display: block;
        width: calc(100% - 40px);
        max-width: 420px;
        margin: 1rem auto 0 auto;
        text-align: center;
        padding: 0.9rem 1rem;
        font-size: 1rem;
    }
}

/* Search & Filter Bar */
.search-filter-bar {
    background: rgba(255, 255, 255, 0.9);
    padding: 1.5rem;
    border-radius: 10px;
    margin: 2rem auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-width: 1200px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.search-box {
    display: flex;
    flex: 1;
    min-width: 250px;
}

.search-box input {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 2px solid #ddd;
    border-radius: 5px 0 0 5px;
    font-size: 1rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-box button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0 1.5rem;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    transition: var(--transition);
}

.search-box button:hover {
    background-color: var(--accent-color);
}

.filter-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-controls select {
    padding: 0.8rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    background-color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.filter-controls select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* App Grid */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 0 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.app-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.app-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.app-card-image {
    height: 160px;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
}

.app-card-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
}

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

.app-card-header {
    display: flex;
    margin-bottom: 0.75rem;
}

.app-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    margin-right: 0.75rem;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.app-card-title {
    flex: 1;
}

.app-card h3 {
    font-size: 1.1rem;
    margin: 0 0 0.25rem;
    color: var(--secondary-color);
}

.app-card-category {
    font-size: 0.8rem;
    color: #666;
    background: #f0f0f0;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    display: inline-block;
}

.app-card-description {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 1rem;
    flex: 1;
}

.app-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.app-rating {
    color: #f1c40f;
    font-size: 0.9rem;
}

.download-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.download-btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.modal-content {
    background-color: white;
    margin: 2rem auto;
    max-width: 900px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close-btn {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    color: #666;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.close-btn:hover {
    color: #333;
    transform: rotate(90deg);
}

.app-details {
    padding: 2rem;
}

.app-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.app-icon-large {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.app-info {
    flex: 1;
    min-width: 200px;
}

.app-title {
    font-size: 1.8rem;
    color: var(--secondary-color);
    margin: 0 0 0.5rem;
    font-family: 'Cinzel Decorative', serif;
}

.app-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.version, .category, .rating {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    color: #666;
}

.rating {
    color: #f1c40f;
}

.rating-count {
    color: #666;
    margin-left: 0.3rem;
}

.app-screenshots {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.screenshot {
    min-width: 200px;
    height: 350px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #eee;
}

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

.app-description {
    line-height: 1.7;
    margin-bottom: 2rem;
}

.app-permissions h3 {
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.permissions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
}

.permissions-list li {
    background: #f5f5f5;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.85rem;
    color: #555;
}

/* Loading overlay for auto-download */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-message {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 80%;
    font-size: 1.2em;
}

.loading-message.success {
    background: #e6ffe6;
    border: 2px solid #4CAF50;
}

.loading-message.error {
    background: #ffe6e6;
    border: 2px solid #f44336;
}

/* Footer */
.marketplace-footer {
    background-color: var(--secondary-color);
    color: var(--text-light);
    padding: 3rem 1rem 1.5rem;
    text-align: center;
    position: relative;
    margin-top: 3rem;
}

.marketplace-footer::before {
    content: '';
    position: absolute;
    top: -30px;
    left: 0;
    right: 0;
    height: 60px;
    background: url('../images/egyptian-pattern-footer.png') top/contain repeat-x;
    opacity: 0.8;
}

.security-note {
    max-width: 800px;
    margin: 0 auto 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
}

.security-note i {
    font-size: 2rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-light);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
}

.footer-links a::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-links a:hover::after {
    width: 100%;
}

.copyright {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content h1 {
        font-size: 2.2rem;
    }
    
    .search-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .app-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .app-info {
        text-align: center;
    }
    
    .app-meta {
        justify-content: center;
    }
    
    .app-screenshots {
        justify-content: flex-start;
    }
    
    .security-note {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Animation for Egyptian theme */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.app-card:hover .app-card-image {
    animation: float 3s ease-in-out infinite;
}

/* Hieroglyphic decorative elements */
.egyptian-divider {
    height: 30px;
    background: url('../images/hieroglyphic-pattern.png') repeat-x;
    margin: 2rem 0;
    opacity: 0.8;
}

/* Decorative pyramids fixed at bottom (marketplace) */
.decor-pyramids {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 520px;
    max-width: 85vw;
    opacity: 0.15;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}

/* Centered Sphinx, half-visible */
.decor-sphinx-center {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -35%);
    width: 60vw;
    max-width: 900px;
    opacity: 0.12;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}
