/* ===== CSS Variables ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #f97316;
    --secondary-dark: #ea580c;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray: #64748b;
    --light: #f1f5f9;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --transition: all 0.3s ease;
    
    /* Mobile-specific variables */
    --mobile-padding: clamp(10px, 3vw, 20px);
    --mobile-gap: clamp(8px, 2vw, 15px);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape */
    -webkit-font-smoothing: antialiased; /* Better font rendering */
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Hero Section ===== */
.hero {
    background: linear-gradient(135deg, #1e3a8a 0%, #3730a3 50%, #4c1d95 100%);
    color: var(--white);
    padding: 80px 20px 100px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::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.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: clamp(1.5rem, 5vw, 4rem);
    font-weight: 700;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.tagline {
    font-size: clamp(0.9rem, 2.5vw, 1.3rem);
    opacity: 0.95;
    font-weight: 400;
}

/* ===== Bootstrap Overrides and Custom Styles ===== */

/* Form overrides */
.form-select {
    border: 2px solid var(--light);
    border-radius: 8px !important;
    font-family: inherit;
    min-height: 44px;
    touch-action: manipulation;
    transition: var(--transition);
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}

.form-select:hover {
    border-color: var(--primary);
}

.form-label {
    color: var(--dark);
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

/* Button overrides */
.btn.check-btn {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
    color: var(--white);
    border: none;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px !important;
    min-height: 44px;
    touch-action: manipulation;
    will-change: transform;
    transition: var(--transition);
}

.btn.check-btn:hover {
    background: linear-gradient(135deg, var(--secondary-dark) 0%, var(--secondary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.btn.check-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.3);
}

.btn.filter-btn {
    background: var(--white);
    border: 2px solid var(--light) !important;
    padding: 10px 20px;
    border-radius: 25px !important;
    font-size: 0.9rem;
    min-height: 40px;
    min-width: 60px;
    touch-action: manipulation;
    transition: var(--transition);
}

.btn.filter-btn:hover {
    border-color: var(--primary) !important;
    color: var(--primary);
    transform: translateY(-1px);
}

.btn.filter-btn:active {
    transform: translateY(0);
}

.btn.filter-btn.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--white) !important;
}

/* ===== SVG Icon Responsive Styling ===== */

/* Base SVG container styling */
.plug-svg {
    display: block;
    max-width: 100%;
    height: auto;
    transition: all 0.3s ease;
}

/* Plug icon containers */
.plug-icon-svg {
    width: clamp(80px, 15vw, 120px);
    height: clamp(53px, 10vw, 80px);
    margin: 0 auto 15px;
    background: var(--white);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    padding: 8px;
    overflow: hidden;
}

.plug-icon-svg svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Visual pair containers for results */
.plug-visual {
    background: var(--white);
    border-radius: 10px;
    padding: 6px;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.plug-visual svg {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
}

/* Hover effects for interactive elements */
.plug-card:hover .plug-svg {
    transform: scale(1.05);
}

.country-card:hover .plug-svg {
    transform: scale(1.02);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .plug-icon-svg {
        width: clamp(60px, 18vw, 80px);
        height: clamp(40px, 12vw, 53px);
        padding: 6px;
        margin-bottom: 12px;
    }
    
    .plug-visual svg {
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    .plug-icon-svg {
        width: clamp(50px, 20vw, 70px);
        height: clamp(33px, 13vw, 47px);
        padding: 5px;
        margin-bottom: 10px;
    }
    
    .plug-photo-grid .plug-visual svg {
        max-width: 90%;
    }
}

/* High DPI display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    .plug-svg {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    .plug-icon-svg {
        background: #2d3748;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    }
}

/* ===== Section Layouts ===== */
.checker-section {
    margin-top: -50px;
    padding-bottom: 60px;
    position: relative;
    z-index: 10;
}

.checker-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.checker-card h2 {
    text-align: center;
    color: var(--dark);
    margin-bottom: 10px;
    font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.checker-card > p {
    text-align: center;
    color: var(--gray);
    margin-bottom: 30px;
}

.checker-form {
    gap: 20px;
}

.swap-icon {
    font-size: 1.5rem;
    padding: 12px;
    cursor: pointer;
    color: var(--primary);
    transition: var(--transition);
    user-select: none;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    touch-action: manipulation;
}

.swap-icon:hover {
    transform: scale(1.1);
    color: var(--primary-dark);
    background: rgba(37, 99, 235, 0.1);
}

.swap-icon:active {
    transform: scale(0.95);
}

.label-icon {
    margin-right: 5px;
}

/* ===== Result Box ===== */
.result {
    margin-top: 25px;
    padding: 25px;
    border-radius: 8px;
    animation: fadeIn 0.3s ease;
}

.result.hidden {
    display: none;
}

.result.success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 2px solid var(--success);
}

.result.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid var(--warning);
}

.result.adapter-needed {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 2px solid var(--danger);
}

.result h3 {
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.result-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.result-detail {
    background: rgba(255,255,255,0.7);
    padding: 12px;
    border-radius: 6px;
}

.result-detail strong {
    display: block;
    color: var(--gray);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.plug-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.plug-badge {
    background: var(--primary);
    color: var(--white);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.plug-badge.compatible {
    background: var(--success);
}

.plug-badge.incompatible {
    background: var(--danger);
}

.plug-photo-section {
    margin-top: 25px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.country-plug-gallery {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.country-plug-gallery h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.plug-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.plug-photo-card {
    background: var(--light);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.plug-photo-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.plug-photo-card.card-match {
    border-color: var(--success);
}

.plug-photo-card.card-adapter {
    border-color: var(--danger);
}

.plug-photo-card.card-home {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.plug-photo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.plug-type-label {
    font-weight: 600;
    color: var(--dark);
}

.plug-status {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-match {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-adapter {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.status-home {
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary);
}

.plug-visual-pair {
    display: flex;
    gap: 10px;
}

.plug-visual {
    flex: 1;
    background: var(--white);
    border-radius: 10px;
    padding: 6px;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}

.plug-visual svg {
    width: 100%;
    height: auto;
    display: block;
}

.plug-photo-card p {
    font-size: 0.8rem;
    color: var(--gray);
    line-height: 1.4;
}

.plug-photo-empty {
    font-size: 0.85rem;
    color: var(--gray);
}

/* ===== Plug Types Section ===== */
.plug-types-section {
    background: var(--white);
    padding: 80px 20px;
}

.plug-types-section h2,
.country-section h2,
.tips-section h2 {
    text-align: center;
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 10px;
    color: var(--dark);
}

.section-subtitle {
    text-align: center;
    color: var(--gray);
    margin-bottom: 40px;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.plug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.plug-card {
    background: var(--light);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    min-height: 120px; /* Consistent height */
    touch-action: manipulation;
    will-change: transform; /* Optimize animations */
}

.plug-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.plug-card:active {
    transform: translateY(-1px);
}

.plug-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: var(--shadow);
}

.plug-icon-svg {
    width: 120px;
    height: 80px;
    margin: 0 auto 15px;
    background: var(--white);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    padding: 10px;
}

.plug-icon-svg svg {
    width: 100%;
    height: 100%;
}

.plug-card h3 {
    color: var(--dark);
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    margin-bottom: 5px;
}

.plug-card p {
    color: var(--gray);
    font-size: clamp(0.75rem, 1.5vw, 0.85rem);
}

.plug-card .voltage {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
}

/* ===== Country Section ===== */
.country-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 80px 20px;
}

.region-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.filter-btn {
    background: var(--white);
    border: 2px solid var(--light);
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
    min-height: 40px; /* Touch-friendly height */
    min-width: 60px;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.filter-btn:active {
    transform: translateY(0);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.country-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.country-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    touch-action: manipulation;
    will-change: transform; /* Optimize animations */
}

.country-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.country-card:active {
    transform: translateY(0);
}

.country-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.country-flag {
    font-size: 2rem;
}

.country-name {
    font-weight: 600;
    color: var(--dark);
    font-size: clamp(1rem, 2.2vw, 1.1rem);
}

.country-region {
    font-size: clamp(0.7rem, 1.5vw, 0.8rem);
    color: var(--gray);
}

.country-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    text-align: center;
}

.country-info-item {
    background: var(--light);
    padding: 10px;
    border-radius: 8px;
}

.country-info-item strong {
    display: block;
    font-size: 0.75rem;
    color: var(--gray);
    margin-bottom: 4px;
}

.country-info-item span {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.country-notes {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--light);
    font-size: 0.85rem;
    color: var(--gray);
}

/* ===== Tips Section ===== */
.tips-section {
    background: var(--white);
    padding: 80px 20px;
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.tip-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: var(--radius);
    padding: 25px;
    text-align: center;
    transition: var(--transition);
}

.tip-card:hover {
    transform: translateY(-3px);
}

.tip-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.tip-card h3 {
    color: var(--dark);
    margin-bottom: 10px;
    font-size: clamp(1rem, 2.2vw, 1.1rem);
}

.tip-card p {
    color: var(--gray);
    font-size: clamp(0.8rem, 1.8vw, 0.9rem);
}

/* ===== Footer ===== */
.footer {
    background: var(--dark);
    color: var(--white);
    padding: 40px 20px;
    text-align: center;
}

.footer p {
    margin-bottom: 10px;
}

.footer-note {
    font-size: 0.85rem;
    opacity: 0.7;
}

.footer-links {
    margin-top: 15px;
}

.footer-links a {
    color: var(--secondary);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

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

/* ===== Mobile Performance & Accessibility ===== */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    }
    
    /* Optimize animations for mobile */
    .plug-card:hover,
    .country-card:hover,
    .tip-card:hover,
    .filter-btn:hover {
        transform: none; /* Disable hover effects on touch devices */
    }
    
    /* Focus states for accessibility */
    .check-btn:focus,
    .form-group select:focus,
    .filter-btn:focus {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }
}

/* ===== Responsive Design with Bootstrap ===== */

/* Mobile adjustments */
@media (max-width: 767px) {
    .checker-card {
        padding: 25px 20px;
    }
    
    .swap-icon {
        transform: rotate(90deg);
        margin: 10px 0;
    }
    
    .plug-icon-svg {
        width: 80px;
        height: 50px;
    }
    
    .plug-icon {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    
    .result-details {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* Extra small devices */
@media (max-width: 575px) {
    .hero {
        padding: 40px 15px 60px;
    }
    
    .checker-section {
        margin-top: -30px;
    }
    
    .checker-card {
        padding: 20px 15px;
    }
    
    .plug-icon-svg {
        width: 70px;
        height: 45px;
    }
    
    .plug-card {
        padding: 15px 10px;
    }
    
    .country-card {
        padding: 15px;
    }
    
    .tip-card {
        padding: 20px 15px;
    }
    
    .btn.filter-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-width: 70px;
    }
    
    .plug-types-section,
    .country-section,
    .tips-section {
        padding: 40px 15px;
    }
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .plug-card:hover,
    .country-card:hover,
    .tip-card:hover {
        transform: none !important;
    }
    
    .btn.filter-btn:hover {
        transform: none !important;
    }
}
