:root {
    --primary-color: #4facfe;
    --secondary-color: #00f2fe;
    --bg-color: #1a1a2e;
    --text-color: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.1);
    --card-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-color), #16213e);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.glass-container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 15px;
    box-shadow: var(--glass-shadow);
    padding: 2rem;
}

/* Login Page Specifics */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-form {
    width: 100%;
    max-width: 400px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-control {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 5px;
    color: white;
    font-size: 1rem;
}

.table-responsive {
    width: 100%;
    /* Default behavior for desktop: no forced scroll unless needed */
    overflow-x: visible;
}

/* Ensure table doesn't force container expansion */
table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th,
td {
    padding: 10px;
    /* Reduced padding for mobile */
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: scale(1.02);
}

/* Main Header */
.main-header {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--card-border);
}

.logo h1 {
    font-size: 1.8rem;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.main-header nav a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 15px;
    font-weight: 500;
    transition: color 0.3s;
}

.main-header nav a:hover {
    color: var(--primary-color);
}

.search-bar {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px;
    border-radius: 20px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: white;
    padding: 5px 10px;
    outline: none;
}

.search-bar button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0 10px;
}

/* App Grid */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem;
}

.app-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    text-decoration: none;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.app-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 40px rgba(0, 242, 254, 0.2);
    border-color: var(--primary-color);
}

.app-card img {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    margin-bottom: 1rem;
    object-fit: cover;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.app-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.app-card .category {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 5px;
}

.app-card .rating {
    color: gold;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.app-card .price {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 0.9rem;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    /* Desktop default */
    gap: 2rem;
}

@media(min-width: 1024px) {
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
        /* Force 4 columns on large screens */
    }
}

/* Footer */
.main-footer {
    text-align: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.3);
    color: #aaa;
    margin-top: auto;
}

.main-footer a {
    color: #aaa;
    text-decoration: none;
    font-size: 0.8rem;
}

/* App Details */
.details-container {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

@media(max-width: 768px) {
    .details-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

.details-icon img {
    width: 150px;
    height: 150px;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.details-info h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.details-meta {
    margin-bottom: 20px;
    color: #ccc;
}

.download-btn {
    display: inline-block;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 5px 20px rgba(0, 242, 254, 0.4);
    transition: transform 0.2s;
}


/* Mobile Optimizations */
@media (max-width: 768px) {

    /* Prevent horizontal scroll on body */
    body,
    html {
        overflow-x: hidden;
        width: 100%;
    }

    .main-header {
        flex-direction: column;
        gap: 15px;
        position: sticky;
        top: 0;
        background: rgba(26, 26, 46, 0.98);
        /* Higher opacity */
        padding: 15px;
        width: 100%;
    }

    /* Horizontal Scrollable Menu Chips */
    .main-header nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        gap: 10px;
        padding-bottom: 5px;
        width: 100%;
        -webkit-overflow-scrolling: touch;
        mask-image: linear-gradient(to right, black 90%, transparent 100%);
        /* Fade effect */
    }

    .main-header nav::-webkit-scrollbar {
        height: 0px;
        /* Hide scrollbar for cleaner look */
        background: transparent;
    }

    .main-header nav a {
        font-size: 0.85rem;
        margin: 0;
        white-space: nowrap;
        background: rgba(255, 255, 255, 0.08);
        padding: 8px 14px;
        border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        flex-shrink: 0;
        /* Prevent shrinking */
    }

    .search-bar {
        width: 100%;
        margin-top: 5px;
    }

    /* Mobile Grid - 2 columns with safe spacing */
    .app-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0 12px;
        width: 100%;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 cols for categories too */
        gap: 10px;
        padding: 0 12px;
    }

    .main-container {
        padding: 15px 0;
        width: 100%;
        overflow-x: hidden;
        /* Double protection */
    }

    .app-card {
        padding: 12px;
    }

    .app-card img {
        width: 50px;
        height: 50px;
    }

    .app-card h3 {
        font-size: 0.9rem;
    }

    /* Better details page on mobile */
    .details-container {
        padding: 0 15px;
    }

    .details-icon img {
        width: 120px;
        height: 120px;
    }

    /* Card View for Tables on Mobile */
    .table-responsive {
        border: none;
        overflow-x: hidden;
        /* No scrolling needed */
        padding-bottom: 0;
        display: block;
    }

    .table-responsive::-webkit-scrollbar {
        display: none;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
        width: 100%;
    }

    /* Hide header row */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* Card styling for each row */
    tr {
        margin-bottom: 15px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.03);
        /* Slightly lighter */
        padding: 5px;
        /* Compact row padding */
    }

    /* Cell styling */
    td {
        /* Act like a row */
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 8px;
        /* Tighter padding */
        text-align: right;
        min-height: 35px;
        font-size: 0.9rem;
        /* Readable base size */
    }

    td:last-child {
        border-bottom: none;
        justify-content: center;
        /* Center buttons */
        padding-top: 15px;
        padding-bottom: 5px;
        gap: 10px;
    }

    /* Label via data-label */
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary-color);
        text-align: left;
        margin-right: auto;
        /* Push content to right */
        padding-right: 10px;
        /* Spacing */
        font-size: 0.85rem;
        /* Slightly smaller label */
        flex-shrink: 0;
        /* Prevent label from squashing */
    }

    /* Adjust specific columns */
    td[data-label="Ícone"] {
        padding: 15px;
        justify-content: center;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 8px 8px 0 0;
        /* Top rounded only */
        margin: -5px -5px 10px -5px;
        /* Pull to edges */
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    td[data-label="Ícone"]::before {
        display: none;
        /* Hide label for icon */
    }

    td[data-label="Ícone"] img {
        width: 60px;
        /* Larger icon for card header feel */
        height: 60px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }

    .glass-container {
        padding: 15px;
        /* Comfortable padding */
        overflow: visible;
    }
}

/* Ultra Small Screens (Moto G4 - 360px) */
@media (max-width: 380px) {
    .glass-container {
        padding: 10px;
    }

    td {
        font-size: 0.85rem;
        padding: 8px 5px;
    }

    td::before {
        font-size: 0.8rem;
    }

    /* Allow wrapping if value is long */
    td[data-label="Nome"],
    td[data-label="Categoria"] {
        flex-wrap: wrap;
    }

    td[data-label="Nome"]::before,
    td[data-label="Categoria"]::before {
        width: 100%;
        margin-bottom: 3px;
    }

    td[data-label="Nome"],
    td[data-label="Categoria"] {
        text-align: left;
        /* Align left when wrapped */
        display: block;
        /* Stack label and value */
    }
}