@import url('https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css');

/* WordPress Plugin Container */
#ah-hearing-test-app {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

/* Override WordPress theme styles that might interfere */
#ah-hearing-test-app .btn {
    text-decoration: none !important;
    line-height: normal !important;
}

#ah-hearing-test-app input,
#ah-hearing-test-app select,
#ah-hearing-test-app button {
    max-width: none !important;
    width: auto;
}

/* Fix for audio visualizer bars in WordPress */
#ah-hearing-test-app .bar {
    width: 12px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    opacity: 0.3 !important;
}

#ah-hearing-test-app .bar.active {
    opacity: 1 !important;
    animation: soundWave 0.8s ease-in-out infinite !important;
}

/* ================ CUSTOM PROPERTIES & ANIMATIONS ================ */
:root {
    /* Dynamic brand colors - overridden by JavaScript */
    --primary-color: #007ace;
    --secondary-color: #0066b3;
    --accent-color: #00A6FB;
    --text-color: #333333;
    --bg-color: #F5F7FA;
    
    /* Original theme colors (fallback) */
    --primary-blue: var(--primary-color);
    --primary-dark: var(--secondary-color);
    --primary-darker: #004d8a;
    --primary-light: #e6f4ff;
    --primary-lighter: #f0f8ff;
    --success-green: #10b981;
    --warning-yellow: #f59e0b;
    --danger-red: #ef4444;
    --gray-100: #f7f9fa;
    --gray-200: #e5e7eb;
    --gray-600: #6b7280;
    --shadow-sm: 0 2px 8px rgba(0, 122, 206, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 122, 206, 0.12);
    --shadow-lg: 0 16px 48px rgba(0, 122, 206, 0.16);
    --shadow-xl: 0 24px 64px rgba(0, 122, 206, 0.2);
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================ GLOBAL STYLES ================ */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    position: relative;
}

/* Animated background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(0, 122, 206, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 102, 179, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(230, 244, 255, 0.08) 0%, transparent 50%);
    animation: backgroundShift 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes backgroundShift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(-20px, -20px) scale(1.05); }
    50% { transform: translate(20px, -20px) scale(0.95); }
    75% { transform: translate(-20px, 20px) scale(1.05); }
}

/* ================ APP CONTAINER & RESPONSIVE LAYOUT ================ */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

/* Mobile-first responsive design */
@media (min-width: 640px) {
    .app-container {
        padding: 2rem;
    }
}

@media (min-width: 768px) {
    .app-container {
        padding: 3rem 2rem;
    }
}

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

/* ================ CARD COMPONENT ================ */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 122, 206, 0.1);
    transition: var(--transition-base);
    animation: fadeInUp 0.6s ease-out;
    position: relative;
    overflow: hidden;
}

/* Gradient border effect */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-dark), var(--primary-blue));
    background-size: 200% 100%;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

@media (min-width: 640px) {
    .card {
        padding: 2rem;
    }
}

@media (min-width: 768px) {
    .card {
        padding: 3rem;
    }
}

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

/* ================ ANIMATIONS ================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* ================ TYPOGRAPHY ================ */
h1, h2, h3 {
    color: #1f2937;
    line-height: 1.2;
}

/* Responsive typography */
h2 {
    font-size: 1.75rem;
}

@media (min-width: 640px) {
    h2 {
        font-size: 2rem;
    }
}

@media (min-width: 768px) {
    h2 {
        font-size: 2.25rem;
    }
}

/* ================ FORM STYLES ================ */
.form-input {
    width: 100%;
    border: 2px solid var(--gray-200);
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    transition: var(--transition-base);
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 206, 0.1);
    transform: translateY(-1px);
}

.form-input:hover {
    border-color: rgba(0, 122, 206, 0.3);
}

/* Mobile touch-friendly input sizes */
@media (max-width: 640px) {
    .form-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 1rem;
    }
}

/* ================ BUTTON STYLES ================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition-base);
    user-select: none;
    cursor: pointer;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 48px; /* Touch-friendly size */
}

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

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

.btn-blue {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 122, 206, 0.3);
}

.btn-blue:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 122, 206, 0.4);
}

.btn-blue:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 122, 206, 0.3);
}

.btn-blue:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-outline {
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
    background: transparent;
}

.btn-outline:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 122, 206, 0.2);
}

.btn-modern {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    box-shadow: 0 8px 24px rgba(0, 122, 206, 0.35);
    transform: translateY(0);
    font-size: 1.125rem;
    padding: 1rem 2.5rem;
}

.btn-modern:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 32px rgba(0, 122, 206, 0.45);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
}

/* Mobile-friendly button sizes */
@media (max-width: 640px) {
    .btn {
        width: 100%;
        padding: 1rem 1.5rem;
    }
}

/* ================ DISCLAIMER STYLES ================ */
.disclaimer {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    padding: 1.25rem;
    border-radius: 1rem;
    border: 2px solid #fbbf24;
    margin-top: 1.5rem;
    position: relative;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.disclaimer::before {
    content: '⚠️';
    position: absolute;
    top: -10px;
    left: 20px;
    font-size: 1.5rem;
    background: white;
    padding: 0 8px;
}

/* ================ SETUP SCREEN STYLES ================ */
.setup-instructions {
    background: var(--primary-lighter);
    border-radius: 1rem;
    padding: 1.5rem;
    animation: fadeInUp 0.6s ease-out;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: white;
    border-radius: 1rem;
    border: 2px solid transparent;
    transition: var(--transition-base);
    animation: fadeInUp 0.6s ease-out;
}

.instruction-item:hover {
    border-color: var(--primary-blue);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.instruction-icon {
    font-size: 2rem;
    min-width: 3.5rem;
    width: 3.5rem;
    height: 3.5rem;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-dark));
    color: white;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounceIn 0.8s ease-out;
    box-shadow: 0 4px 12px rgba(0, 122, 206, 0.3);
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .instruction-item {
        padding: 1rem;
    }
    
    .instruction-icon {
        min-width: 3rem;
        width: 3rem;
        height: 3rem;
        font-size: 1.5rem;
    }
}

/* ================ PROGRESS BAR ================ */
.progress-bar-bg {
    background-color: var(--gray-200);
    border-radius: 9999px;
    overflow: hidden;
    height: 16px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar-fg {
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--primary-dark) 50%, var(--primary-blue) 100%);
    background-size: 200% 100%;
    height: 100%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 9999px;
    position: relative;
    animation: gradientShift 2s ease-in-out infinite;
}

/* Animated stripes */
.progress-bar-fg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 30px 30px;
    animation: progressStripes 1s linear infinite;
}

@keyframes progressStripes {
    0% { background-position: 0 0; }
    100% { background-position: 30px 0; }
}

/* ================ AUDIO DISPLAY & VISUALIZER ================ */
.audio-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-lighter) 0%, white 100%);
    border-radius: 2rem;
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    border: 2px solid rgba(0, 122, 206, 0.1);
    animation: fadeInUp 0.6s ease-out;
}

@media (max-width: 640px) {
    .audio-display {
        padding: 1.5rem;
        min-width: 100%;
    }
}

.audio-visualizer {
    position: relative;
}

.visualizer-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 100px;
    padding: 10px;
}

.bar {
    width: 12px;
    background: linear-gradient(to top, var(--primary-blue), var(--primary-dark), var(--primary-light));
    border-radius: 6px 6px 0 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.3;
    transform-origin: bottom;
}

.bar.active {
    opacity: 1;
    animation: soundWave 0.8s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(0, 122, 206, 0.5);
}

.bar-1 { height: 20%; animation-delay: 0s; }
.bar-2 { height: 40%; animation-delay: 0.1s; }
.bar-3 { height: 60%; animation-delay: 0.2s; }
.bar-4 { height: 80%; animation-delay: 0.3s; }
.bar-5 { height: 100%; animation-delay: 0.4s; }

@keyframes soundWave {
    0%, 100% { 
        transform: scaleY(1);
        filter: brightness(1);
    }
    50% { 
        transform: scaleY(1.3);
        filter: brightness(1.2);
    }
}

.audio-level {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.level-value {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
    animation: pulse 2s ease-in-out infinite;
}

@media (max-width: 640px) {
    .level-value {
        font-size: 3rem;
    }
}

/* ================ VOLUME CONTROLS ================ */
.volume-control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1.25rem;
    background: white;
    border: 3px solid var(--gray-200);
    border-radius: 1.25rem;
    cursor: pointer;
    transition: var(--transition-base);
    min-width: 110px;
    position: relative;
}

.volume-control-btn:hover {
    border-color: var(--primary-blue);
    background: var(--primary-light);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 122, 206, 0.3);
}

.volume-control-btn:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 122, 206, 0.25);
}

.volume-icon {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--primary-blue);
    transition: var(--transition-base);
}

.volume-control-btn:hover .volume-icon {
    transform: scale(1.2);
    color: var(--primary-dark);
}

/* ================ PLAY/PAUSE BUTTON ================ */
.btn.playing {
    background: linear-gradient(135deg, var(--success-green), #059669);
    color: white;
    border-color: var(--success-green);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
    transform: translateY(-2px);
    animation: pulse 2s ease-in-out infinite;
}

.btn.playing:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(16, 185, 129, 0.45);
}

/* ================ EAR TRANSITION CARD ================ */
.ear-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.ear-transition-card {
    background: white;
    border-radius: 2rem;
    padding: 3rem;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: bounceIn 0.6s ease-out;
}

.transition-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
}

.ear-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.left-ear-icon {
    background: #fecaca;
    color: #dc2626;
    animation: pulse 2s ease-in-out infinite;
}

.right-ear-icon {
    background: #dbeafe;
    color: var(--primary-blue);
    animation: pulse 2s ease-in-out infinite 0.5s;
}

.arrow {
    font-size: 2rem;
    color: var(--gray-600);
    animation: slideRight 1s ease-in-out infinite;
}

@keyframes slideRight {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(10px); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ================ AUDIOGRAM STYLES ================ */
.audiogram-container {
    background: linear-gradient(135deg, var(--primary-lighter) 0%, white 100%);
    border-radius: 1.5rem;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: var(--shadow-lg);
    border: 2px solid rgba(0, 122, 206, 0.1);
    animation: fadeInUp 0.8s ease-out;
}

@media (max-width: 768px) {
    .audiogram-container {
        padding: 1rem;
        margin: 1rem 0;
    }
}

.audiogram-chart {
    position: relative;
    width: 100%;
    height: 550px;
    background: white;
    border: 3px solid #374151;
    margin: 2rem 0;
    padding: 50px 50px 80px 80px;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .audiogram-chart {
        height: 400px;
        padding: 40px 40px 60px 60px;
    }
}

@media (max-width: 640px) {
    .audiogram-chart {
        height: 350px;
        padding: 30px 30px 50px 50px;
    }
}

.audiogram-point {
    position: absolute;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    z-index: 10;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: var(--transition-base);
    animation: bounceIn 0.6s ease-out;
}

.audiogram-point:hover {
    transform: translate(-50%, -50%) scale(1.5);
}

.audiogram-point.left-ear {
    color: #dc2626;
}

.audiogram-point.right-ear {
    color: var(--primary-blue);
}

/* ================ RESULTS SECTION ================ */
.results-card {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.hearing-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 1.125rem;
    margin: 1.5rem 0;
    animation: bounceIn 1s ease-out 0.3s both;
}

.status-normal {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
    border: 2px solid #10b981;
}

.status-mild {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    border: 2px solid #f59e0b;
}

.status-moderate {
    background: linear-gradient(135deg, #fed7aa, #fdba74);
    color: #7c2d12;
    border: 2px solid #fb923c;
}

.status-severe {
    background: linear-gradient(135deg, #fecaca, #fca5a5);
    color: #7f1d1d;
    border: 2px solid #ef4444;
}

.hearing-score-display {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .hearing-score-display {
        gap: 1rem;
    }
}

.ear-score {
    background: white;
    border-radius: 1.5rem;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--gray-200);
    transition: var(--transition-base);
    animation: fadeInUp 0.8s ease-out;
}

.ear-score:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-blue);
}

.score-value {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    margin: 0.5rem 0;
}

@media (max-width: 640px) {
    .score-value {
        font-size: 2.5rem;
    }
}

#left-ear-score .score-value {
    color: #dc2626;
}

#right-ear-score .score-value {
    color: var(--primary-blue);
}

/* ================ SHOP BUTTON ================ */
.shop-btn {
    background: linear-gradient(135deg, var(--success-green), #059669);
    color: white;
    padding: 1.25rem 3rem;
    font-size: 1.25rem;
    border: none;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
    position: relative;
    overflow: hidden;
}

.shop-btn::before {
    content: '🛒';
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    transition: left 0.3s ease;
}

.shop-btn:hover::before {
    left: 20px;
}

.shop-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-3px) scale(1.02);
    padding-left: 4rem;
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.45);
}

/* ================ BRAND HEADER ================ */
.brand-header {
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
    background-color: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.brand-logo {
    max-height: 60px;
    max-width: 200px;
    object-fit: contain;
}

/* ================ UTILITY CLASSES ================ */
.hidden {
    display: none !important;
}

/* Touch-friendly tap targets */
@media (hover: none) {
    .btn, .volume-control-btn, .form-input {
        min-height: 48px;
    }
}

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

/* Print styles */
@media print {
    body {
        background: white;
    }
    
    .btn, .volume-control-btn {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
}