/* App Component Styles */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-light: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --transition: all 0.2s ease;
    --form-control-size: 1.25rem; /* Base size for checkboxes and radio buttons */
}

/* Mobile-friendly form controls */
input[type="checkbox"],
input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    margin: 0;
    width: var(--form-control-size);
    height: var(--form-control-size);
    border: 2px solid #d1d5db;
    border-radius: 0.25rem;
    background-color: white;
    display: inline-grid;
    place-content: center;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

/* Radio button specific styles */
input[type="radio"] {
    border-radius: 50%;
}

/* Checked state for both */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Checkmark for checkboxes */
input[type="checkbox"]:checked::before {
    content: "";
    width: 0.4em;
    height: 0.7em;
    border: solid white;
    border-width: 0 0.15em 0.15em 0;
    transform: rotate(45deg);
    position: relative;
    top: -1px;
}

/* Dot for radio buttons */
input[type="radio"]:checked::before {
    content: "";
    width: 0.5em;
    height: 0.5em;
    border-radius: 50%;
    background-color: white;
}

/* Focus states */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Hover states */
input[type="checkbox"]:hover:not(:disabled),
input[type="radio"]:hover:not(:disabled) {
    border-color: var(--primary-hover);
}

/* Disabled state */
input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Larger touch targets on mobile */
@media (max-width: 640px) {
    :root {
        --form-control-size: 1.5rem; /* Slightly larger on mobile */
    }
    
    /* Ensure labels with checkboxes/radios have proper touch targets */
    label.flex.items-center {
        padding: 0.5rem 0;
    }
    
    /* Increase spacing for radio button labels */
    .flex.items-center.p-3.border.rounded-lg {
        padding: 0.75rem;
    }
    
    /* Make sure the clickable area is large enough */
    input[type="checkbox"] + span,
    input[type="radio"] + .ml-3 {
        margin-left: 0.75rem;
    }
}

/* Base App Section */
.app-section {
    padding: 1.5rem 0;
    background: #fff;
    position: relative;
}

.app-section.bg-alt {
    background: var(--bg-light);
}

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

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 0 0.5rem;
    /* border-radius: 1.5rem; */

}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.app-subtitle {
    display: block;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.app-link {
    color: var(--primary-color);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: var(--transition);
}

.app-link:hover {
    color: var(--primary-hover);
}

/* Scroll Container */
.app-scroll-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0.5rem 1.5rem;
    margin: 0 -0.5rem;
}

.app-scroll-container::-webkit-scrollbar {
    display: none;
}

.app-scroll-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.app-scroll-content {
    display: inline-flex;
    gap: 1rem;
    padding: 0 0.5rem;
}

/* App Card */
.app-card {
    position: relative;
    width: 180px;
    background: white;
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.app-card:active {
    transform: scale(0.98);
}

.app-card:hover {
    box-shadow: var(--shadow-md);
}

/* Rank Badge */
.app-rank-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 2;
}

.app-rank-badge.gold { 
    background: linear-gradient(135deg, #FFD700, #FFA500); 
}
.app-rank-badge.silver { 
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0); 
}
.app-rank-badge.bronze { 
    background: linear-gradient(135deg, #CD7F32, #A0522D); 
}

/* Avatar */
.app-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 1rem;
    background: #f3f4f6;
    border: 3px solid white;
    box-shadow: var(--shadow-sm);
}

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

.app-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    color: #9ca3af;
    background: #f3f4f6;
}

/* Card Content */
.app-card-content {
    width: 100%;
    text-align: center;
    margin-bottom: 1rem;
}

.app-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.app-card-subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Card Action */
.app-card-action {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 500;
    width: 100%;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    transition: var(--transition);
}

.app-card-action:hover {
    color: var(--primary-hover);
}

.app-card-arrow {
    width: 16px;
    height: 16px;
    margin-left: 0.25rem;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Format Badge */
.format-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
    margin: 0.125rem;
}

.format-badge.ebook {
    background-color: #e0f2fe;
    color: #0369a1;
}

.format-badge.paperback {
    background-color: #e0f2fe;
    color: #0369a1;
}

.format-badge.hardcover {
    background-color: #ede9fe;
    color: #6d28d9;
}

/* Responsive Adjustments */
@media (min-width: 640px) {
    .app-card {
        width: 200px;
    }
    
    .app-avatar {
        width: 90px;
        height: 90px;
    }
}

/* Safe area for notches */
@supports (padding: max(0px)) {
    .app-container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}
