/* Mobile and Responsive Fixes for OneUPI */

/* Responsive table improvements */
@media (max-width: 768px) {
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td,
    .data-table tr {
        display: block;
    }
    
    .data-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .data-table tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 8px;
        background: white;
    }
    
    .data-table td {
        border: none;
        position: relative;
        padding-left: 50% !important;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    
    .data-table td:before {
        content: attr(data-label) ": ";
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: #374151;
    }
}

/* Responsive navigation improvements */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .sidebar-menu {
        display: none;
        background: white;
        border-radius: 8px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        margin: 1rem;
    }
    
    .sidebar-menu.active {
        display: block;
    }
    
    .mobile-menu-toggle {
        display: block;
        background: #667eea;
        color: white;
        border: none;
        padding: 1rem;
        margin: 1rem;
        border-radius: 8px;
        font-weight: 600;
        cursor: pointer;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
}

/* Card and grid responsive improvements */
@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .pricing-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }
    
    .notification-cards {
        grid-template-columns: 1fr !important;
    }
    
    .features-grid {
        grid-template-columns: 1fr !important;
    }
    
    .service-cards-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Form responsive improvements */
@media (max-width: 640px) {
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
}

/* Button improvements */
@media (max-width: 640px) {
    .hero-cta,
    .btn-primary,
    .btn-secondary {
        width: 100%;
        text-align: center;
        margin-bottom: 1rem;
    }
    
    .nav-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Text and typography responsive */
@media (max-width: 640px) {
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .section-title {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    .welcome-title {
        font-size: 2rem;
    }
    
    .page-header h1 {
        font-size: 1.75rem;
    }
}

/* Loading states */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error states */
.error-message {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-message i {
    color: #dc2626;
}

.success-message {
    background: #d1fae5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.success-message i {
    color: #065f46;
}

/* Improved accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus improvements */
button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Enhanced Login UI Styles */
.modal-content {
    max-width: 450px;
    padding: 2rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #ffffff;
}

.form-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.form-input:invalid {
    border-color: #ef4444;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
}

.form-group label i {
    margin-right: 0.5rem;
    color: #667eea;
}

.input-help {
    margin-top: 0.25rem;
}

.input-help small {
    color: #6b7280;
    font-size: 0.875rem;
}

.password-input-group {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
}

.password-toggle:hover {
    color: #374151;
}

.btn-full {
    width: 100%;
    justify-content: center;
    margin-bottom: 1rem;
}

.loading-state {
    text-align: center;
    padding: 2rem;
}

.loading-state p {
    margin-top: 1rem;
    color: #6b7280;
}

.login-options {
    margin: 1.5rem 0;
}

.divider {
    text-align: center;
    margin: 1rem 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e5e7eb;
}

.divider span {
    background: white;
    padding: 0 1rem;
    color: #6b7280;
    font-size: 0.875rem;
}

/* OTP Input Styles */
.otp-header {
    text-align: center;
    margin-bottom: 2rem;
}

.otp-header i {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.otp-header h4 {
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.otp-header p {
    color: #6b7280;
}

.otp-input-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 2rem 0;
}

.otp-input {
    width: 3rem;
    height: 3rem;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
}

.otp-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.otp-input.filled {
    border-color: #10b981;
    background: #f0f9ff;
}

.otp-timer {
    text-align: center;
    margin: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.otp-timer span {
    font-weight: 600;
    color: #ef4444;
}

.resend-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
}

.resend-btn:disabled {
    color: #9ca3af;
    cursor: not-allowed;
    text-decoration: none;
}

.resend-btn:hover:not(:disabled) {
    color: #4f46e5;
}

/* Button States */
.btn-primary:disabled,
.btn-outline:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary.loading {
    position: relative;
    color: transparent;
}

.btn-primary.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #1f2937;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000;
        color: #fff;
        border: 2px solid #000;
    }
    
    .btn-outline {
        background: #fff;
        color: #000;
        border: 2px solid #000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1f2937;
        --bg-secondary: #374151;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
    }
    
    body {
        background-color: var(--bg-primary);
        color: var(--text-primary);
    }
    
    .modal-content,
    .card,
    .settings-card {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }
}
