/**
 * Shorto Pro - Custom Styles
 * Responsive and performance-optimized CSS
 */

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

/* Global Styles */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Ensure proper spacing for all containers */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

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

@media (min-width: 1024px) {
    .container {
        padding: 0 2rem;
    }
}

/* Glass morphism effect */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Gradient backgrounds */
.gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.gradient-success {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Animation classes */
.animate-fade-in {
    animation: fadeIn 0.8s ease-out;
    will-change: opacity, transform;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-slide-up {
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-pulse-slow {
    animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

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

/* Form enhancements */
.form-input {
    transition: all 0.3s ease;
    will-change: background-color, border-color, box-shadow;
}

.form-input:focus {
    outline: none;
    ring: 2px;
    ring-opacity: 50%;
    border-opacity: 40%;
}

/* Button enhancements */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    will-change: background-color, transform, box-shadow;
}

.btn:active {
    transform: translateY(1px);
}

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Advanced sections */
.advanced-section {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.advanced-section.active {
    max-height: 600px;
}

.bot-page-section {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.bot-page-section.active {
    max-height: 300px;
}

/* Dashboard styles */
.dashboard-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

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

.stat-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: #cbd5e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Chart containers */
.chart-container {
    position: relative;
    min-height: 300px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 1rem;
}

.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #64748b;
}

/* Enhanced Mobile Optimizations */
@media (max-width: 768px) {
    /* Typography scaling for mobile */
    .text-5xl { font-size: 2.5rem; line-height: 1.1; }
    .text-4xl { font-size: 2rem; line-height: 1.2; }
    .text-3xl { font-size: 1.875rem; line-height: 1.25; }
    .text-2xl { font-size: 1.5rem; line-height: 1.3; }
    .text-xl { font-size: 1.125rem; line-height: 1.4; }
    
    /* Better spacing for mobile */
    .p-8, .p-10, .p-12 { padding: 1.5rem !important; }
    .p-6 { padding: 1rem !important; }
    .px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
    .py-4 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
    
    .mb-8, .mb-10, .mb-12 { margin-bottom: 1.5rem !important; }
    .mb-6 { margin-bottom: 1rem !important; }
    .mt-8, .mt-10, .mt-12 { margin-top: 1.5rem !important; }
    
    /* Icon and element sizing */
    .w-20.h-20 { width: 4rem !important; height: 4rem !important; }
    .w-16.h-16 { width: 3rem !important; height: 3rem !important; }
    .w-12.h-12 { width: 2.5rem !important; height: 2.5rem !important; }
    
    /* Form improvements */
    .form-input, input, textarea, select {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 0.75rem 1rem !important;
    }
    
    /* Better spacing between elements */
    .space-y-6 > * + * { margin-top: 1rem !important; }
    .space-y-4 > * + * { margin-top: 0.75rem !important; }
    .space-y-8 > * + * { margin-top: 1.5rem !important; }
    
    /* Chart and card containers */
    .chart-container {
        min-height: 250px;
        padding: 0.75rem;
        margin: 0.5rem 0;
    }
    
    /* Enhanced table handling */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0.5rem;
        margin: 1rem 0;
    }
    
    .table-responsive table {
        min-width: 600px; /* Ensure minimum width for readability */
    }
    
    /* Mobile-optimized buttons */
    .btn, .btn-mobile {
        min-height: 44px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 0.75rem 1.5rem !important;
        touch-action: manipulation;
    }
    
    /* Hide less important content on small screens */
    .hide-mobile {
        display: none !important;
    }
    
    /* Show mobile-specific content */
    .show-mobile {
        display: block !important;
    }
    
    /* Stack form elements vertically on mobile */
    .form-stack-mobile {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    /* Ensure proper touch targets */
    .touch-target {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
    }
    
    /* Navigation improvements */
    .nav-mobile {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
    }
    
    /* Card stacking */
    .card-stack-mobile {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Text content spacing */
    .content-mobile {
        text-align: left;
        line-height: 1.6;
    }
    
    .content-mobile p {
        margin-bottom: 1rem;
    }
    
    /* Better visual hierarchy on mobile */
    .glass {
        border-radius: 1rem !important;
        margin: 0.5rem 0 !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    /* Even smaller text scaling */
    .text-5xl { font-size: 2rem !important; line-height: 1.1; }
    .text-4xl { font-size: 1.75rem !important; line-height: 1.2; }
    .text-3xl { font-size: 1.5rem !important; line-height: 1.25; }
    .text-2xl { font-size: 1.25rem !important; line-height: 1.3; }
    .text-xl { font-size: 1.125rem !important; line-height: 1.4; }
    
    /* Tighter spacing on very small screens */
    .p-8, .p-6, .p-10, .p-12 { padding: 1rem !important; }
    .px-4 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .py-3 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
    
    .mb-6, .mb-8 { margin-bottom: 1rem !important; }
    .mb-4 { margin-bottom: 0.75rem !important; }
    .mt-6, .mt-8 { margin-top: 1rem !important; }
    
    /* Smaller containers */
    .chart-container {
        min-height: 200px;
        padding: 0.5rem;
        margin: 0.25rem 0;
    }
    
    /* More compact forms */
    .form-input, input, textarea, select {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Smaller buttons but still touch-friendly */
    .btn {
        padding: 0.5rem 1rem !important;
        min-height: 40px !important;
    }
    
    /* Navigation adjustments */
    .nav-mobile {
        padding: 0.5rem;
    }
    
    /* Grid adjustments */
    .grid {
        gap: 0.75rem !important;
    }
    
    /* Icon sizing */
    .w-16.h-16 { width: 2.5rem !important; height: 2.5rem !important; }
    .w-12.h-12 { width: 2rem !important; height: 2rem !important; }
    
    /* Content padding */
    .container {
        padding: 0 0.75rem !important;
    }
    
    /* Table responsiveness */
    .table-responsive table {
        font-size: 0.875rem;
    }
    
    /* Card improvements */
    .glass {
        padding: 0.75rem !important;
        border-radius: 0.75rem !important;
    }
}

/* Performance improvements */
input, textarea, button {
    will-change: background-color, border-color;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .animate-fade-in,
    .animate-slide-up,
    .animate-pulse-slow {
        animation: none;
    }
    
    .advanced-section,
    .bot-page-section {
        transition: none;
    }
    
    .btn,
    .form-input,
    .dashboard-card,
    .stat-card {
        transition: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .dashboard-card {
        background: rgba(30, 41, 59, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
        color: #f1f5f9;
    }
    
    .stat-card {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        border-color: #475569;
        color: #f1f5f9;
    }
}

/* Enhanced Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox scrollbar styling */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.05);
}

/* Print styles */
@media print {
    .no-print {
        display: none;
    }
    
    .print-break {
        page-break-after: always;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .glass,
    .dashboard-card,
    .stat-card {
        background: white !important;
        border: 1px solid #ccc !important;
    }
}

/* Focus indicators for accessibility */
.focus-visible:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .glass {
        background: rgba(255, 255, 255, 0.9);
        border-color: rgba(0, 0, 0, 0.3);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* Enhanced Selection Styles */
::selection {
    background: rgba(59, 130, 246, 0.3);
    color: inherit;
}

::-moz-selection {
    background: rgba(59, 130, 246, 0.3);
    color: inherit;
}

/* Prevent text selection on UI elements */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection on content */
.select-text {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Screen reader only text */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Skip to main content link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* Focus management for better accessibility */
.focus-visible:focus {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 2px;
}

/* Alpine.js cloak - hide content until Alpine.js is loaded */
[x-cloak] {
    display: none !important;
}