/* Dashboard Styling */

.dashboard-container {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg-primary);
}

/* Sidebar Navigation */
.dashboard-sidebar {
    width: 280px;
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: var(--spacing-xl);
}

.sidebar-header .logo-text {
    font-size: 1.5rem;
    display: block;
    margin-bottom: var(--spacing-xs);
}

.sidebar-user {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    padding: var(--spacing-sm);
    background: var(--color-bg-tertiary);
    border-radius: 8px;
    margin-bottom: var(--spacing-md);
    
    /* Truncate long emails with ellipsis */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.nav-item:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.nav-item.active {
    background: var(--color-primary);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-item.disabled:hover {
    background: transparent;
    color: var(--color-text-secondary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

.btn-logout {
    width: 100%;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    justify-content: center;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Main Content Area */
.dashboard-main {
    flex: 1;
    margin-left: 280px;
    padding: var(--spacing-xl);
    max-width: 1400px;
}

.dashboard-header {
    margin-bottom: var(--spacing-xl);
}

.dashboard-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-xs);
}

.dashboard-subtitle {
    color: var(--color-text-secondary);
    font-size: 1.1rem;
}

/* Dashboard Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.dashboard-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: var(--spacing-xl);
    transition: all var(--transition-normal);
}

.dashboard-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.card-icon svg {
    width: 24px;
    height: 24px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.card-content {
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

.card-footer {
    display: flex;
    gap: var(--spacing-sm);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.status-badge.pending {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

/* Info Box */
.info-box {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.info-box-title {
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-sm);
}

.info-box-content {
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* Form Elements */
.form-section {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
}

.form-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-md);
}

.form-row {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.form-row .form-group {
    flex: 1;
}

.input-with-button {
    display: flex;
    gap: var(--spacing-sm);
}

.input-with-button input {
    flex: 1;
}

/* Table Styles */
.data-table {
    width: 100%;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    font-weight: 600;
    text-align: left;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: var(--color-bg-tertiary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--color-text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-sm);
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Alerts */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: 12px;
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--color-primary);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.alert-warning {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fbbf24;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* Responsive Design */
@media (max-width: 968px) {
    .dashboard-sidebar {
        width: 240px;
    }
    
    .dashboard-main {
        margin-left: 240px;
    }
}

@media (max-width: 768px) {
    .dashboard-sidebar {
        position: fixed;
        left: -280px;
        z-index: 1000;
        transition: left var(--transition-normal);
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        overflow-y: auto;
        overflow-x: hidden;
        /* Smooth scrolling on iOS */
        -webkit-overflow-scrolling: touch;
    }
    
    .dashboard-sidebar.open {
        left: 0;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
    }
    
    /* Ensure sidebar footer is always visible and accessible */
    .sidebar-footer {
        padding-bottom: 2rem; /* Extra space at bottom for mobile safe area */
        margin-bottom: env(safe-area-inset-bottom, 0); /* iOS safe area */
    }
    
    .dashboard-main {
        margin-left: 0;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    /* Mobile menu toggle button */
    .mobile-menu-toggle {
        display: flex;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 999;
        background: var(--color-bg-secondary);
        border: 1px solid var(--color-border);
        border-radius: 8px;
        padding: 0.75rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .mobile-menu-toggle:hover {
        background: var(--color-bg-tertiary);
        border-color: var(--color-primary);
    }
    
    .mobile-menu-toggle svg {
        width: 24px;
        height: 24px;
        color: var(--color-text);
    }
    
    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Ensure sidebar footer is visible on mobile */
    .sidebar-footer {
        display: block;
        padding-bottom: 2rem;
    }
}

/* ===== PURCHASE PAGE ===== */

/* Platform Toggle */
.purchase-toggle {
    display: inline-flex;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 2rem;
}

.purchase-toggle-btn {
    padding: 0.6rem 1.8rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.purchase-toggle-btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.purchase-toggle-btn:not(.active):hover {
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Plans Grid */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    max-width: 900px;
    margin-bottom: 2rem;
}

.plan-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.plan-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
}

.plan-card.featured {
    border-color: var(--color-primary);
}

.plan-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--color-primary);
    color: white;
    padding: 6px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 0 18px 0 12px;
}

.plan-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.75rem;
}

.plan-price {
    font-size: 2.75rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    line-height: 1;
}

.plan-price .period {
    font-size: 1rem;
    color: var(--color-text-secondary);
    font-weight: 400;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.plan-feature {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

.plan-feature svg {
    flex-shrink: 0;
}

.plan-feature.excluded {
    color: #ef4444;
}

.plan-includes {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.plan-includes strong {
    color: var(--color-primary);
}

.plan-btn {
    width: 100%;
    padding: 0.85rem;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    text-decoration: none;
    display: block;
    box-sizing: border-box;
    line-height: 1.5;
}

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

.plan-btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.plan-btn-secondary {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.plan-btn-secondary:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

.plan-btn-disabled {
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    cursor: not-allowed;
    opacity: 0.7;
}

.plan-btn-disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Autosolver Card */
.autosolver-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 2rem;
    max-width: 900px;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.autosolver-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
}

.autosolver-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.autosolver-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.autosolver-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
}

.autosolver-price .period {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    font-weight: 400;
}

.autosolver-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
}

.autosolver-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

/* Purchase Info */
.purchase-info {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    max-width: 900px;
}

.purchase-info-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.75rem;
}

.purchase-info p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    line-height: 1.8;
    margin: 0;
}

.purchase-info p + p {
    margin-top: 0.25rem;
}

/* Platform sections */
.platform-section {
    display: none;
}

.platform-section.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .plans-grid {
        grid-template-columns: 1fr;
    }

    .autosolver-features {
        grid-template-columns: 1fr;
    }

    .autosolver-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Spinner animation for download button */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}