/* Enhanced SaaS Styles for Tweet Predictor */

/* Import Inter font for consistency */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Base body styling */
body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #cbd5e1 100%);
    min-height: 100vh;
}

/* Main gradient background */
.saas-gradient {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 25%, #334155 75%, #3b82f6 100%);
}

/* Glass morphism cards with enhanced browser support */
.saas-card {
    /* Firefox and older browser fallback */
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: 0.75rem;
}

/* Enhanced glass effect for supporting browsers */
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
    .saas-card {
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.2);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
}

/* Dark theme cards */
.saas-card-dark {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border-radius: 0.75rem;
}

/* Header pattern styling */
.header-pattern {
   background-image: 
        linear-gradient(135deg, rgba(29, 161, 242, 0.9) 0%, rgba(91, 112, 131, 0.8) 50%, rgba(20, 23, 26, 0.9) 100%),
        radial-gradient(circle at 20% 30%, rgba(29, 161, 242, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(91, 112, 131, 0.3) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.08'%3E%3Cpath d='M30 25c-2.8 0-5 2.2-5 5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0-5c5.5 0 10 4.5 10 10s-4.5 10-10 10-10-4.5-10-10 4.5-10 10-10z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: cover, 200px 200px, 250px 250px, 60px 60px;
    background-position: center, top left, bottom right, center;
    background-repeat: no-repeat, no-repeat, no-repeat, repeat;
    position: relative;
    overflow: hidden;
}

.header-pattern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
}

/* Primary button styling */
.saas-button {
    background-image: linear-gradient(to right, #2563eb, #1e40af);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.saas-button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.3);
}

.saas-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Secondary button styling */
.saas-button-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.saas-button-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.3);
}

/* Input field styling */
.input-field {
    border: 1px solid #cbd5e1;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: rgba(248, 250, 252, 0.8);
}

.input-field:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Loading spinner */
.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Auth modal styling */
.auth-modal {
    /* Firefox fallback */
    background: rgba(0, 0, 0, 0.85);
}

/* Enhanced blur effect for supporting browsers */
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
    .auth-modal {
        background: rgba(0, 0, 0, 0.5);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
    }
}

/* Auth tabs styling */
.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.auth-tab {
    flex-grow: 1;
    text-align: center;
    padding: 0.75rem 0;
    cursor: pointer;
    font-weight: 500;
    color: #64748b;
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
    border-bottom: 2px solid transparent;
}

.auth-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* Analysis tabs styling */
.analysis-tabs {
    display: flex;
    background: #f1f5f9;
    border-radius: 0.5rem;
    padding: 0.25rem;
    margin-bottom: 1.5rem;
}

.analysis-tab {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-weight: 500;
    color: #64748b;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.analysis-tab.active {
    background: #2563eb;
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.analysis-tab:hover:not(.active) {
    background: #e2e8f0;
    color: #475569;
}

/* Content tabs visibility */
.analysis-content {
    display: block;
}

.analysis-content.hidden {
    display: none;
}

.results-content {
    display: block;
}

.results-content.hidden {
    display: none;
}

/* Twitter integration styling */
.twitter-verify-box {
    background-color: #f1f5f9;
}

.twitter-button {
    background-color: #1da1f2;
    transition: all 0.3s ease;
}

.twitter-button:hover {
    background-color: #1a91da;
    transform: translateY(-2px);
}

/* Message modal styling */
.message-modal {
    /* Firefox fallback */
    background: rgba(0, 0, 0, 0.75);
}

@supports (backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px)) {
    .message-modal {
        background: rgba(0, 0, 0, 0.5);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }
}

.message-box {
    background-color: #fff;
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Progress bar styling */
.progress-container {
    width: 100%;
    background: #e2e8f0;
    border-radius: 0.5rem;
    height: 0.75rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #1e40af);
    border-radius: 0.5rem;
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(45deg, 
        rgba(255,255,255,.2) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255,255,255,.2) 50%, 
        rgba(255,255,255,.2) 75%, 
        transparent 75%, 
        transparent);
    background-size: 1rem 1rem;
    animation: progress-animation 1s linear infinite;
}

@keyframes progress-animation {
    0% { background-position: 0 0; }
    100% { background-position: 1rem 0; }
}

/* Score circle styling */
.score-circle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 6rem;
    height: 6rem;
}

.score-inner {
    background: white;
    border-radius: 50%;
    width: 80%;
    height: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Analysis breakdown styling */
.analysis-details {
    background: #f8fafc;
    border-radius: 0.5rem;
    padding: 1rem;
    border-left: 3px solid #2563eb;
}

/* Suggestion items */
.suggestion-item {
    padding: 0.75rem;
    background: #fef7cd;
    border-radius: 0.375rem;
    border-left: 3px solid #f59e0b;
    font-size: 0.875rem;
}

/* History items */
.history-item {
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    border: 1px solid rgba(59, 130, 246, 0.1);
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    padding: 1rem;
}

.history-item:hover {
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}

.history-item-content {
    font-size: 0.875rem;
    color: #475569;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.history-item-score {
    font-weight: 700;
    font-size: 1.125rem;
}

.history-item-meta {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.5rem;
}

/* Demo tweet styling */
.demo-tweet {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    position: relative;
}

.demo-tweet:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #2563eb;
}

.demo-tweet-score {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #2563eb;
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Comparison styling */
.comparison-variant {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.comparison-winner {
    border-color: #10b981;
    background: #ecfdf5;
}

.comparison-loser {
    border-color: #ef4444;
    background: #fef2f2;
}

.comparison-tie {
    border-color: #f59e0b;
    background: #fffbeb;
}

.comparison-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.comparison-metric {
    text-align: center;
}

.comparison-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.comparison-metric-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Batch analysis styling */
.batch-result-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.batch-tweet-preview {
    flex: 1;
    font-size: 0.875rem;
    color: #475569;
    margin-right: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.batch-score {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2563eb;
    min-width: 3rem;
    text-align: right;
}

/* Tips styling */
.tip-item {
    position: relative;
    overflow: hidden;
}

.tip-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: currentColor;
}

/* Character count styling with color states */
#charCount, #charCountA, #charCountB {
    font-size: 0.875rem;
    color: #64748b;
    transition: color 0.2s ease;
}

#charCount.warning, #charCountA.warning, #charCountB.warning {
    color: #f59e0b;
}

#charCount.danger, #charCountA.danger, #charCountB.danger {
    color: #ef4444;
}

/* Usage indicator styling */
#usageIndicator {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Export button styling */
.export-options {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.export-option {
    flex: 1;
    padding: 0.5rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    color: #475569;
}

.export-option:hover {
    background: #e2e8f0;
    border-color: #2563eb;
    color: #2563eb;
}

.export-option.active {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

/* Status colors */
.success-color {
    color: #10b981;
}

.warning-color {
    color: #f59e0b;
}

.danger-color {
    color: #ef4444;
}

/* Enhanced input focus states */
textarea:focus,
input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Enhanced button states */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .analysis-tabs {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .analysis-tab {
        padding: 0.75rem;
        border-radius: 0.375rem;
    }
    
    .comparison-metrics {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .score-circle {
        width: 5rem;
        height: 5rem;
    }
    
    .batch-result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .batch-tweet-preview {
        margin-right: 0;
    }
}

/* Enhanced fallback for browsers without backdrop-filter support */
@supports not ((backdrop-filter: blur()) or (-webkit-backdrop-filter: blur())) {
    .saas-card {
        /* More opaque background for browsers without blur support */
        background: rgba(255, 255, 255, 0.99) !important;
        border: 1px solid rgba(226, 232, 240, 0.9) !important;
        /* Add subtle inner shadow to simulate depth */
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.8);
    }
    
    .auth-modal {
        /* More opaque background without blur */
        background: rgba(0, 0, 0, 0.9) !important;
    }
    
    .message-modal {
        /* More opaque background without blur */
        background: rgba(0, 0, 0, 0.85) !important;
    }
    
    /* Enhanced input styling for better definition */
    .input-field {
        background: rgba(248, 250, 252, 0.98);
        border: 1px solid rgba(203, 213, 225, 0.8);
    }
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* Animation classes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

.animate-slideIn {
    animation: slideIn 0.3s ease-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Utility classes for spacing and layout */
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-x-2 > * + * { margin-left: 0.5rem; }
.space-x-3 > * + * { margin-left: 0.75rem; }
.space-x-4 > * + * { margin-left: 1rem; }

/* Print styles */
@media print {
    .auth-modal,
    .message-modal,
    .progress-modal,
    .saas-button,
    #logoutBtn,
    #demoBtn,
    .analysis-tabs,
    .export-options {
        display: none !important;
    }
    
    .saas-card {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #e2e8f0 !important;
    }
    
    body {
        background: white !important;
    }
    
    .header-pattern {
        background: #2563eb !important;
        color: white !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .saas-card {
        border: 2px solid #000;
        background: #fff;
    }
    
    .analysis-tab.active {
        background: #000;
        color: #fff;
    }
    
    .saas-button {
        background: #000;
        color: #fff;
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
        border: 4px solid #2563eb;
        border-top-color: transparent;
    }
}
