:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --accent-color: #f72585;
    --kaywat-color: #4361ee; /* Blue color for Kaywat */
    --codes-color: #f72585; /* Pink color for Codes */
    --background-color: #0a0a0c; /* Deeper dark background */
    --header-bg: #121214; /* Slightly lighter than background */
    --text-color: #f0f0f5; /* Bright text for contrast */
    --text-light: #a0a0b0; /* Subdued text color */
    --card-bg: #18181b; /* Card background for depth */
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Safe Area Insets */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

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

html {
    font-size: clamp(14px, 1.2vw + 10px, 18px);
    width: 100%;
    overflow-x: hidden;
    position: relative;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.6;
    width: 100%;
    overflow-x: hidden;
}

img, video, iframe, embed, object, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
    }
}

/* Header Styles */
header {
    background-color: var(--header-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: var(--safe-top);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

/* Logo Container */
.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 20px;
}

/* Custom Logo Box */
.logo {
    display: flex;
    align-items: center;
    font-size: 24px;
    font-weight: 700;
    text-decoration: none;
    min-width: 180px;
    background-color: #000;
    padding: 5px 10px;
    border: 1px solid #333;
    border-radius: 4px;
}

.logo-icon {
    color: #FFD700;
    font-size: 28px;
}

.brand-kaywat {
    color: var(--kaywat-color);
}

.brand-space {
    display: inline-block;
    width: 2px;
}

.brand-codes {
    color: var(--codes-color);
}

.nav-search-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

/* Navigation & Touch Targets */
a, button, input, select, textarea,
[role="button"], [role="tab"], [role="menuitem"],
.btn, .nav-link, .featured {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-link {
    text-decoration: none;
    color: white;
    font-weight: 500;
    margin: 0 10px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Fluid Typography */
h1 { font-size: clamp(2rem, 5vw + 1rem, 3.5rem); line-height: 1.1; margin-bottom: 1.5rem; }
h2 { font-size: clamp(1.5rem, 4vw + 0.5rem, 2.5rem); line-height: 1.2; margin-bottom: 1.25rem; }
h3 { font-size: clamp(1.2rem, 3vw + 0.3rem, 1.75rem); line-height: 1.3; margin-bottom: 1rem; }
p, li { font-size: clamp(0.95rem, 1vw + 0.7rem, 1.1rem); line-height: 1.6; margin-bottom: 1rem; }

h1, h2, h3, h4, h5, h6, p, li, a, span {
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

.nav-link.disabled {
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}

.nav-link:hover {
    color: var(--codes-color);
}

.nav-link.featured {
    background-color: #3B4CCA;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    margin-left: 15px;
    display: inline-flex;
    align-items: center;
    transition: all 0.3s ease;
}

.nav-link.featured:hover {
    background-color: #FF0000;
    color: white;
    transform: translateY(-2px);
}

.left-nav {
    display: flex;
    justify-content: flex-end;
}

.right-nav {
    display: flex;
    justify-content: flex-start;
}

.nav-search {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    flex-grow: 1;
}

.nav-search input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 30px;
    border: 1px solid #333;
    background-color: #fff;
    font-size: 0.9rem;
    outline: none;
    padding-right: 40px;
}

.nav-search button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--kaywat-color);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-search button:hover {
    background: var(--secondary-color);
}

nav ul {
    display: flex;
    list-style: none;
    gap: 25px;
}

nav a {
    text-decoration: none;
    color: white;
    font-weight: 500;
    transition: var(--transition);
}

nav a:hover {
    color: var(--codes-color);
}

/* Mobile Navigation Overlay */
@media (max-width: 767px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: fixed;
        inset: 0;
        background: rgba(18, 18, 18, 0.98);
        backdrop-filter: blur(15px);
        justify-content: center;
        align-items: center;
        z-index: 9999;
        padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
        gap: 1.5rem;
        overflow-y: auto;
    }

    .nav-links.is-open {
        display: flex;
    }

    .nav-links .nav-link {
        font-size: 1.5rem;
        width: 100%;
        text-align: center;
        margin: 0;
        color: white;
    }

    .nav-links .nav-link.featured {
        width: auto;
        font-size: 1.25rem;
        padding: 12px 24px;
    }

    .hamburger {
        display: flex;
        flex-direction: column;
        gap: 6px;
        background: transparent;
        border: none;
        cursor: pointer;
        z-index: 10000;
        padding: 0.5rem;
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
        align-items: center;
        color: white;
    }

    .hamburger span {
        display: block;
        width: 24px;
        height: 2px;
        background: currentColor;
        transition: transform 0.3s ease, opacity 0.3s ease;
        border-radius: 2px;
    }

    .hamburger.is-open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .hamburger.is-open span:nth-child(2) { opacity: 0; }
    .hamburger.is-open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

    .logo {
        min-width: auto;
        font-size: 1.1rem;
        z-index: 10001; /* Stay above overlay if needed */
    }

    .header-container {
        padding: 0.75rem 0;
    }

    .nav-link:not(.featured) {
        /* Standard hidden state moved to .nav-links wrapper */
    }
}

@media (min-width: 768px) {
    .hamburger { display: none; }
    .nav-links { 
        display: flex; 
        flex-direction: row; 
        gap: 10px;
    }
}

/* Touch device adjustments */
@media (hover: none) and (pointer: coarse) {
    .btn:hover, .nav-link:hover, .app-card:hover {
        transform: none !important;
        box-shadow: inherit !important;
    }
}

/* Hero Section */
.hero {
    padding: calc(60px + var(--safe-top)) 0 80px;
    background: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
    color: white;
    text-align: center;
    border-radius: 0 0 30px 30px;
    min-height: 50dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    line-height: 1.2;
}

.hero h1 .brand-kaywat,
.hero h1 .brand-codes {
    display: inline-block;
}

.hero h1 .brand-kaywat {
    color: #ffffff;
}

.hero h1 .brand-codes {
    color: #f72585;
}

.hero p {
    font-size: 1.2rem;
    max-width: 800px;
    margin: 0 auto 30px;
    opacity: 0.9;
}

.hero-search {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.hero-search input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid transparent;
    border-radius: 5px;
    font-size: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.hero-search input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 2px 15px rgba(0, 123, 255, 0.25);
}

.hero-search button {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    padding: 0 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.hero-search button:hover {
    background: #0056b3;
}

.hero-search button:before {
    content: "🔍";
    font-size: 16px;
}

/* Search Results Dropdown */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(18, 18, 20, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    margin-top: 2px;
    max-height: 450px;
    overflow-y: auto;
    display: none;
    z-index: 1100;
    border: 1px solid rgba(67, 97, 238, 0.3);
    border-top: none;
    text-align: left;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--text-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(67, 97, 238, 0.05);
}

.search-result-icon {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    margin-right: 15px;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.search-result-info {
    flex: 1;
    min-width: 0; /* Ensures text truncation works */
}

.search-result-title {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1rem;
    margin-bottom: 2px;
    display: block;
}

.search-result-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.search-result-meta {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    font-size: 0.75rem;
}

.search-result-badge {
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.search-result-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

.search-result-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}

.search-result-btn-download {
    background: var(--primary-color);
    color: white !important;
}

.search-result-btn-download:hover {
    background: var(--secondary-color);
}

.search-result-btn-view {
    border: 1px solid var(--primary-color);
    color: var(--primary-color) !important;
}

.search-result-btn-view:hover {
    background: rgba(67, 97, 238, 0.2);
}

/* Custom Scrollbar for Search Results */
.search-results-dropdown::-webkit-scrollbar {
    width: 8px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0 12px 0;
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Ensure hero-search input doesn't overlap the border-radius when results are open */
.hero-search.results-open input {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Carousel Styles */
.carousel-section {
    position: relative;
    padding: 60px 0;
    overflow: hidden;
    background: var(--background-color);
}

.carousel-section .container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.app-carousel {
    position: relative;
    width: 100%;
    padding: 0 40px;
    margin: 0;
    display: flex;
    align-items: stretch;
}

.carousel-item {
    padding: 0;
    flex: 1;
    display: flex;
}

.carousel-section .app-card {
    display: flex;
    flex-direction: column;
    max-height: 500px;
    height: 100%;
    width: 100%;
    margin: 0;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.carousel-section .carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border: none;
    color: white;
    transition: background-color 0.3s ease;
    margin: 0;
    padding: 0;
}

.carousel-section .carousel-nav.prev {
    left: 0;
}

.carousel-section .carousel-nav.next {
    right: 0;
}

.slick-track {
    display: flex;
    align-items: stretch;
    margin: 0;
}

.slick-slide {
    height: auto;
    margin: 0;
    padding: 0 15px;
}

.slick-list {
    margin: 0;
    padding: 0;
}

.slick-prev,
.slick-next {
    width: 40px;
    height: 40px;
    z-index: 10;
}

.slick-prev {
    left: -5px;
}

.slick-next {
    right: -5px;
}

.slick-prev:before,
.slick-next:before {
    font-size: 40px;
    color: var(--primary-color);
}

.slick-dots {
    bottom: -30px;
}

.slick-dots li button:before {
    font-size: 12px;
    color: var(--primary-color);
}

/* Category Section */
.categories {
    padding: 60px 0;
}

.section-title {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2rem;
    color: var(--text-color);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.category-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    transition: var(--transition);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.category-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.category-card h3 {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.category-card p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Featured Apps Section */
.featured-apps {
    padding: 60px 0;
    background-color: var(--background-color);
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
    /* Add margin to separate from section-note */
}

.app-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    height: 100%;
    /* Ensure all cards have same height */
    display: flex;
    flex-direction: column;
}

.app-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.app-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.app-info {
    padding: 20px;
    flex-grow: 1;
    /* Allow content to expand */
    display: flex;
    flex-direction: column;
}

.app-title {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.app-description {
    color: var(--text-light);
    margin-bottom: 15px;
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
    /* Allow description to expand */
}

.app-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    /* Push to bottom */
}

.app-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    padding: 8px 15px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background-color: var(--kaywat-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--codes-color);
}

.btn-outline {
    border: 1px solid var(--kaywat-color);
    color: var(--kaywat-color);
}

.btn-outline:hover {
    background-color: var(--kaywat-color);
    color: white;
}

/* About Section */
.about {
    padding: 80px 0;
    text-align: center;
}

.about-content {
    max-width: 800px;
    margin: 0 auto;
}

.about h2 {
    margin-bottom: 20px;
}

.about p {
    margin-bottom: 20px;
    color: var(--text-light);
}

/* Support Section */
.support {
    padding: 80px 0;
    background-color: #f9f9f9;
    text-align: center;
}

.support-content {
    max-width: 800px;
    margin: 0 auto;
}

.support-options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 30px;
}

.support-card {
    background-color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    flex: 1;
    min-width: 230px;
    transition: var(--transition);
}

.support-card:hover {
    transform: translateY(-5px);
}

.support-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

/* Footer */
footer {
    background-color: #1e1e1e;
    color: white;
    padding: 60px 0 20px;
}

.footer-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section h3 {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.footer-section h3 .brand-kaywat {
    color: var(--kaywat-color);
}

.footer-section h3 .brand-codes {
    color: var(--codes-color);
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: white;
    text-decoration: underline;
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.2rem;
    transition: var(--transition);
}

.social-link:hover {
    background-color: var(--primary-color);
    transform: translateY(-3px);
}

.copyright {
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}
