/**
 * Responsive CSS Framework for ai.izmereniya.tech
 * Mobile-first responsive design system
 *
 * Breakpoints:
 * - Small Mobile: < 480px
 * - Mobile: 480px - 768px
 * - Tablet: 768px - 1024px
 * - Desktop: > 1024px
 */

/* =====================================================
   CSS Variables - Responsive Values
   ===================================================== */
:root {
    /* Spacing - fluid values using clamp() */
    --spacing-xs: clamp(4px, 1vw, 8px);
    --spacing-sm: clamp(8px, 2vw, 16px);
    --spacing-md: clamp(16px, 3vw, 24px);
    --spacing-lg: clamp(24px, 4vw, 32px);
    --spacing-xl: clamp(32px, 5vw, 48px);

    /* Font sizes - fluid typography */
    --text-xs: clamp(10px, 2.5vw, 12px);
    --text-sm: clamp(12px, 2.8vw, 14px);
    --text-md: clamp(14px, 3vw, 16px);
    --text-lg: clamp(16px, 3.5vw, 20px);
    --text-xl: clamp(20px, 4vw, 28px);
    --text-xxl: clamp(28px, 5vw, 42px);
    --text-hero: clamp(32px, 6vw, 56px);

    /* Container */
    --container-padding: clamp(16px, 5vw, 40px);
    --max-width: 1200px;

    /* Touch targets */
    --touch-target-min: 44px;

    /* Colors (shared) */
    --primary-color: #4a6cf7;
    --primary-dark: #3a5bd9;
    --text-dark: #333;
    --text-muted: #666;
    --border-color: #e0e0e0;
    --bg-light: #f5f7fa;
    --success-color: #2e7d32;
    --error-color: #c62828;
    --warning-color: #ef6c00;
}

/* =====================================================
   Base Responsive Styles
   ===================================================== */

/* Prevent iOS zoom on input focus */
input, select, textarea {
    font-size: 16px !important;
}

/* Responsive images */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Responsive embed container */
.responsive-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
}

.responsive-embed iframe,
.responsive-embed video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* =====================================================
   Touch Device Optimizations
   ===================================================== */

/* Remove hover effects on touch devices */
@media (hover: none) {
    .card:hover,
    .btn:hover,
    .action-btn:hover,
    button:hover {
        transform: none !important;
        box-shadow: inherit !important;
    }
}

/* Active states for touch feedback */
@media (hover: none) {
    .btn:active,
    button:active,
    .action-btn:active,
    a:active {
        opacity: 0.8;
        transform: scale(0.98) !important;
    }
}

/* Ensure touch targets are large enough */
@media (max-width: 768px) {
    button,
    .btn,
    input[type="submit"],
    input[type="button"],
    .nav-link,
    .action-btn {
        min-height: var(--touch-target-min);
    }

    input[type="checkbox"],
    input[type="radio"] {
        width: 22px !important;
        height: 22px !important;
        min-width: 22px !important;
    }
}

/* =====================================================
   Form Responsive Styles
   ===================================================== */

/* Full-width forms on mobile */
@media (max-width: 768px) {
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 16px;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Form options (remember me / forgot password) */
@media (max-width: 480px) {
    .form-options {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
}

/* =====================================================
   Auth Pages Responsive (Login, Register, etc.)
   ===================================================== */

/* Container adjustments for small screens */
@media (max-width: 480px) {
    .login-container,
    .register-container,
    .container {
        margin: 10px;
        border-radius: 16px !important;
    }

    .login-header,
    .register-header,
    .header {
        padding: 20px 15px !important;
    }

    .login-header h1,
    .register-header h1 {
        font-size: var(--text-lg) !important;
    }

    .login-header p,
    .register-header p {
        font-size: var(--text-sm) !important;
    }

    .login-form,
    .register-form,
    .form-container {
        padding: 20px 15px !important;
    }
}

/* Back button positioning on small screens */
@media (max-width: 480px) {
    .page-back-link {
        top: 10px !important;
        left: 10px !important;
        padding: 8px 14px !important;
        font-size: 13px !important;
    }
}

/* =====================================================
   Index Page (Webflow) Responsive
   ===================================================== */

/* Header responsive */
@media (max-width: 991px) {
    .header .quick-stack {
        flex-wrap: wrap;
        gap: 10px;
    }

    .header .top_cell_l {
        flex: 1 1 100%;
        text-align: center;
    }

    .header .top_cellr1,
    .header .top_cellr2 {
        flex: 1 1 auto;
    }
}

@media (max-width: 767px) {
    .header {
        padding: 15px !important;
    }

    .header .btn {
        padding: 10px 16px !important;
        font-size: 14px !important;
    }

    .header .image-3 {
        width: 120px !important;
    }
}

/* Hero section responsive */
@media (max-width: 991px) {
    .grid_hero {
        grid-template-columns: 1fr !important;
    }

    .cell_left {
        text-align: center;
        padding: 20px !important;
    }

    .heading {
        font-size: var(--text-xl) !important;
        line-height: 1.3 !important;
    }

    .sell_right {
        padding: 20px !important;
    }
}

@media (max-width: 767px) {
    .section_hero {
        padding: 20px 10px !important;
    }

    .heading {
        font-size: var(--text-lg) !important;
    }

    .grid_cell_right {
        grid-template-columns: auto 1fr auto !important;
        gap: 10px !important;
    }

    .h2 {
        font-size: 24px !important;
    }

    .pgf {
        font-size: 14px !important;
    }

    .img {
        width: 80px !important;
        height: 80px !important;
        object-fit: cover;
        border-radius: 8px;
    }
}

@media (max-width: 479px) {
    .heading {
        font-size: 20px !important;
        padding: 0 10px;
    }

    .cell_left .btn {
        width: 100%;
        text-align: center;
    }
}

/* =====================================================
   Dashboard Responsive
   ===================================================== */

@media (max-width: 992px) {
    .cards-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .dashboard-header,
    .header {
        padding: 15px !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    .header-logo {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px !important;
    }

    .header-title {
        display: none;
    }

    .header-user {
        width: 100%;
        justify-content: center;
    }

    .user-name {
        display: none !important;
    }

    .main-content {
        padding: 15px !important;
    }

    .welcome-section {
        padding: 20px !important;
    }

    .welcome-section h1 {
        font-size: var(--text-lg) !important;
    }

    .card-body {
        padding: 15px !important;
    }

    .quick-actions {
        justify-content: center;
    }

    .action-btn {
        flex: 1 1 calc(50% - 10px);
        min-width: 120px;
        padding: 15px !important;
    }

    .profile-item {
        flex-direction: column;
        gap: 5px;
    }

    .profile-label {
        font-weight: 500;
    }
}

@media (max-width: 480px) {
    .action-btn {
        flex: 1 1 100%;
    }

    .action-btn .icon {
        font-size: 24px !important;
    }

    .btn-logout {
        padding: 8px 16px !important;
        font-size: 13px !important;
    }
}

/* =====================================================
   Privacy Policy / Terms Responsive
   ===================================================== */

.policy-container,
.terms-container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--container-padding);
}

@media (max-width: 768px) {
    .policy-content,
    .terms-content {
        padding: 20px !important;
    }

    .policy-content h1,
    .terms-content h1 {
        font-size: var(--text-xl) !important;
    }

    .policy-content h2,
    .terms-content h2 {
        font-size: var(--text-lg) !important;
    }

    .policy-content p,
    .terms-content p,
    .policy-content li,
    .terms-content li {
        font-size: var(--text-md) !important;
        line-height: 1.7 !important;
    }
}

/* =====================================================
   404 Page Responsive
   ===================================================== */

@media (max-width: 480px) {
    .error-code {
        font-size: 80px !important;
    }

    .error-title {
        font-size: var(--text-lg) !important;
    }

    .error-description {
        font-size: var(--text-md) !important;
        padding: 0 10px;
    }

    .actions {
        flex-direction: column !important;
        width: 100%;
        padding: 0 20px;
    }

    .actions .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    .suggestions-list {
        flex-direction: column !important;
        gap: 10px !important;
    }
}

/* =====================================================
   Hamburger Menu (for future implementation)
   ===================================================== */

.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    cursor: pointer;
    z-index: 1000;
}

.hamburger-menu span {
    display: block;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 6px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -6px);
}

@media (max-width: 767px) {
    .hamburger-menu {
        display: flex;
    }

    .mobile-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: white;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        z-index: 999;
        padding: 80px 20px 20px;
    }

    .mobile-nav.active {
        right: 0;
    }

    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 998;
    }

    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .mobile-nav-link {
        display: block;
        padding: 15px 0;
        border-bottom: 1px solid var(--border-color);
        color: var(--text-dark);
        text-decoration: none;
        font-weight: 500;
        font-size: 16px;
    }

    .mobile-nav-link:hover {
        color: var(--primary-color);
    }
}

/* =====================================================
   Utility Classes
   ===================================================== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 1024px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
@media (min-width: 768px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* Text alignment responsive */
@media (max-width: 767px) {
    .text-center-mobile {
        text-align: center !important;
    }
}

/* Stack on mobile */
@media (max-width: 767px) {
    .stack-mobile {
        flex-direction: column !important;
    }

    .stack-mobile > * {
        width: 100% !important;
    }
}

/* =====================================================
   Safe Area Insets (for notched devices)
   ===================================================== */

@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .fixed-bottom,
    .mobile-bottom-nav {
        padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
    }
}

/* =====================================================
   Print Styles
   ===================================================== */

@media print {
    .page-back-link,
    .hamburger-menu,
    .mobile-nav,
    .mobile-nav-overlay,
    .btn-logout,
    .header-back {
        display: none !important;
    }

    body {
        background: white !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }
}

/* =====================================================
   Captcha Responsive
   ===================================================== */

@media (max-width: 480px) {
    .captcha-container {
        margin: 15px 0 !important;
    }

    .smart-captcha {
        transform: scale(0.9);
        transform-origin: center;
    }

    #captcha-container {
        display: flex;
        justify-content: center;
    }
}

/* =====================================================
   Privacy Consent Checkbox Responsive
   ===================================================== */

@media (max-width: 480px) {
    .privacy-consent {
        margin-top: 20px !important;
        padding-top: 15px !important;
    }

    .consent-wrapper {
        gap: 10px !important;
    }

    .consent-label {
        font-size: 12px !important;
        line-height: 1.4 !important;
    }

    .privacy-link {
        margin-left: 30px !important;
    }

    .privacy-link a {
        font-size: 12px !important;
    }
}

/* =====================================================
   Animation Performance on Mobile
   ===================================================== */

@media (max-width: 768px) {
    /* Reduce animations on mobile for better performance */
    *,
    *::before,
    *::after {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    /* Disable parallax and complex animations */
    .parallax {
        background-attachment: scroll !important;
    }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
