/**
 * instaTrader Frontend Styles
 * Mobile-First Responsive Design
 */

/* Reset & Base */
.instatrader-app {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.instatrader-app * {
    box-sizing: border-box;
}

/* App Container */
.instatrader-app {
    min-height: 100vh;
    background-color: #f8fafc;
}

/* Loading State */
.instatrader-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #64748b;
}

.instatrader-loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: instatrader-spin 0.8s linear infinite;
    margin-right: 15px;
}

@keyframes instatrader-spin {
    to { transform: rotate(360deg); }
}

/* Error State */
.instatrader-error {
    padding: 2rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.75rem;
    color: #991b1b;
    text-align: center;
    margin: 1rem;
}

/* Login Required */
.instatrader-login-required {
    padding: 3rem 1.5rem;
    text-align: center;
    background: #f8fafc;
    border-radius: 1rem;
    max-width: 400px;
    margin: 2rem auto;
}

.instatrader-login-required h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e293b;
}

.instatrader-login-required p {
    margin: 0 0 1.5rem 0;
    color: #64748b;
}

.instatrader-login-required a {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: #3b82f6;
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.instatrader-login-required a:hover {
    background: #2563eb;
}

/* Challenge Cards - Standalone CSS (no Tailwind required) */
.instatrader-challenges-container {
    padding: 1rem;
}

@media (min-width: 640px) {
    .instatrader-challenges-container {
        padding: 1.5rem;
    }
}

.challenge-card {
    background: white;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.3s, transform 0.3s;
}

.challenge-card:hover {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.challenge-card-image {
    height: 140px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

@media (min-width: 640px) {
    .challenge-card-image {
        height: 160px;
    }
}

.challenge-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.challenge-card-content {
    padding: 1rem;
}

@media (min-width: 640px) {
    .challenge-card-content {
        padding: 1.5rem;
    }
}

.challenge-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.25rem 0;
}

@media (min-width: 640px) {
    .challenge-card-title {
        font-size: 1.25rem;
    }
}

.challenge-card-balance {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3b82f6;
    margin: 0 0 1rem 0;
}

@media (min-width: 640px) {
    .challenge-card-balance {
        font-size: 1.875rem;
    }
}

.challenge-card-rules {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .challenge-card-rules {
        gap: 0.75rem;
    }
}

.challenge-card-rule {
    background: #f8fafc;
    padding: 0.5rem;
    border-radius: 0.5rem;
    text-align: center;
}

@media (min-width: 640px) {
    .challenge-card-rule {
        padding: 0.75rem;
    }
}

.challenge-card-rule-label {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0;
}

.challenge-card-rule-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.challenge-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.challenge-card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #16a34a;
}

@media (min-width: 640px) {
    .challenge-card-price {
        font-size: 1.5rem;
    }
}

.challenge-card-price del {
    color: #94a3b8;
    font-size: 0.875rem;
    margin-right: 0.5rem;
}

.challenge-card-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: #3b82f6;
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

@media (min-width: 640px) {
    .challenge-card-button {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

.challenge-card-button:hover {
    background: #2563eb;
    color: white;
}

/* Challenge Info on WooCommerce Product Page */
.instatrader-challenge-info {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.75rem;
    border-left: 4px solid #3b82f6;
}

@media (min-width: 640px) {
    .instatrader-challenge-info {
        padding: 1.5rem;
    }
}

.instatrader-challenge-info h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.instatrader-challenge-info ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.instatrader-challenge-info li {
    padding: 0.625rem 0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.instatrader-challenge-info li:last-child {
    border-bottom: none;
}

.instatrader-challenge-info strong {
    color: #475569;
}

/* Responsive Typography */
@media (max-width: 640px) {
    .instatrader-app h1 {
        font-size: 1.5rem;
    }
    
    .instatrader-app h2 {
        font-size: 1.25rem;
    }
    
    .instatrader-app h3 {
        font-size: 1.125rem;
    }
}

/* Touch Targets - Ensure minimum 44px for mobile */
@media (max-width: 640px) {
    .instatrader-app button,
    .instatrader-app a.button,
    .instatrader-app [role="button"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Safe Area Insets for iOS */
@supports (padding: env(safe-area-inset-bottom)) {
    .instatrader-app {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Print Styles */
@media print {
    .instatrader-app nav,
    .instatrader-app .sidebar,
    .instatrader-app button {
        display: none !important;
    }
    
    .instatrader-app {
        background: white;
    }
}
