/* 
 * Unit Converter CSS - Modernized Version
 * SEO-optimized styles with modern design principles
 */

/* CSS Variables for consistent theming */
:root {
    /* Primary color palette */
    --primary-color: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: #4895ef;
    
    /* Secondary colors */
    --secondary-color: #4cc9f0;
    --accent-color: #f72585;
    
    /* Neutral colors */
    --dark: #2b2d42;
    --light: #f8f9fa;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-xxl: 3rem;
    
    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Base styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background-color: var(--gray-100);
    transition: background-color var(--transition-normal);
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: var(--space-sm);
    font-weight: 600;
    line-height: 1.2;
    color: var(--dark);
}

h1 {
    font-size: 2.5rem;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 2rem;
    letter-spacing: -0.3px;
}

h3 {
    font-size: 1.5rem;
}

p {
    margin-bottom: var(--space-md);
}

/* AdSense Banner Styles */
.adsense-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: var(--space-xl);
    background-color: var(--gray-100);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: background-color var(--transition-normal);
}

.adsense-banner-horizontal {
    width: 100%;
    max-width: 720px;
    height: 90px;
    margin: 0 auto var(--space-xl);
}

.adsense-banner-square {
    width: 250px;
    height: 250px;
    margin: 0 auto var(--space-xl);
}

.adsense-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--gray-200);
    color: var(--gray-600);
    font-size: 0.9rem;
    text-align: center;
    border: 1px dashed var(--gray-400);
    transition: all var(--transition-normal);
}

/* Header styles */
header {
    background-color: var(--primary-color);
    color: white;
    padding: var(--space-md) 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.logo-image {
    height: 40px;
    width: auto;
    border-radius: var(--radius-sm);
}

header h1 {
    color: white;
    margin-bottom: 0;
    font-weight: 700;
}

header nav ul {
    display: flex;
    list-style: none;
    flex-wrap: wrap;
    gap: var(--space-md);
}

header nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

header nav ul li a:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

header nav ul li a:active {
    transform: translateY(0);
}

/* Main content styles */
main {
    padding: var(--space-xl) 0;
}

.hero {
    text-align: center;
    margin-bottom: var(--space-xxl);
    padding: var(--space-xl) 0;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transform: translateY(0);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.hero:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.hero h2 {
    margin-bottom: var(--space-md);
    color: white;
}

.hero p {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Converter section styles */
.converter-section {
    margin-bottom: var(--space-xxl);
    padding: var(--space-xl);
    background-color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    animation: fadeIn 0.5s ease-out;
}

.converter-section:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.converter-section h2 {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
    display: inline-block;
}

.converter-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xl);
}

.converter-form {
    flex: 1;
    min-width: 300px;
}

.converter-info {
    flex: 1;
    min-width: 300px;
}

/* Form styles */
form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.input-group, .select-group, .result-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.select-group {
    display: flex;
    flex-direction: row;
    gap: var(--space-md);
}

.from-unit, .to-unit {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

label {
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.95rem;
}

input, select {
    padding: var(--space-md);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-fast);
    background-color: var(--gray-100);
}

input:hover, select:hover {
    border-color: var(--gray-400);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

button {
    padding: var(--space-md) var(--space-lg);
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(0);
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

.result-container {
    position: relative;
    margin-top: var(--space-sm);
}

.result-container input {
    background-color: var(--gray-100);
    font-weight: 600;
    color: var(--primary-color);
    border: 2px solid var(--gray-300);
}

.copy-btn {
    position: absolute;
    right: 0;
    bottom: 0;
    padding: var(--space-sm) var(--space-md);
    background-color: var(--gray-200);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.copy-btn:hover {
    background-color: var(--gray-300);
    color: var(--gray-800);
}

/* Table styles */
.conversion-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-md);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.conversion-table th, .conversion-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--gray-300);
}

.conversion-table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.conversion-table tr:last-child td {
    border-bottom: none;
}

.conversion-table tr:nth-child(even) {
    background-color: var(--gray-100);
}

.conversion-table tr:hover {
    background-color: var(--gray-200);
}

/* Related converters section */
.related-converters h2 {
    margin-bottom: var(--space-lg);
    color: var(--primary-color);
}

.converter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}

.converter-card {
    display: block;
    padding: var(--space-lg);
    background-color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: var(--dark);
    transition: all var(--transition-normal);
    border-top: 4px solid var(--primary-color);
}

.converter-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.converter-card h3 {
    color: var(--primary-color);
    margin-bottom: var(--space-sm);
}

/* About section */
.about-section {
    margin-top: var(--space-xxl);
    padding: var(--space-xl);
    background-color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* Footer styles */
footer {
    background-color: var(--dark);
    color: white;
    padding: var(--space-xxl) 0 var(--space-lg);
    margin-top: var(--space-xxl);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.footer-section h3 {
    color: white;
    margin-bottom: var(--space-md);
    font-size: 1.2rem;
    position: relative;
    padding-bottom: var(--space-sm);
}

.footer-section h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background-color: var(--primary-color);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: var(--space-sm);
}

.footer-section ul li a {
    color: var(--gray-300);
    text-decoration: none;
    transition: color var(--transition-fast);
    display: block;
    padding: var(--space-xs) 0;
}

.footer-section ul li a:hover {
    color: var(--primary-light);
    transform: translateX(5px);
}

.copyright {
    text-align: center;
    padding-top: var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* Responsive styles */
@media (max-width: 768px) {
    header nav ul {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
    
    .converter-container {
        flex-direction: column;
    }
    
    .select-group {
        flex-direction: column;
    }
    
    .adsense-banner-horizontal {
        height: auto;
        max-width: 100%;
    }
    
    .adsense-banner-square {
        width: 100%;
        max-width: 250px;
    }
    
    .hero {
        padding: var(--space-lg) var(--space-md);
    }
    
    .converter-section {
        padding: var(--space-lg) var(--space-md);
    }
}

/* Accessibility improvements */
:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    20% {
        transform: scale(25, 25);
        opacity: 0.5;
    }
    100% {
        opacity: 0;
        transform: scale(40, 40);
    }
}

.converter-section {
    animation: fadeIn 0.5s ease-out;
    animation-fill-mode: both;
}

#length { animation-delay: 0.1s; }
#weight { animation-delay: 0.2s; }
#temperature { animation-delay: 0.3s; }

/* Theme toggle styles (for dark mode) */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    z-index: 999;
    transition: all var(--transition-normal);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle i {
    font-size: 1.5rem;
}

/* Dark mode styles */
body.dark-mode {
    --dark: #f8f9fa;
    --light: #121212;
    --gray-100: #1e1e1e;
    --gray-200: #2d2d2d;
    --gray-300: #3d3d3d;
    --gray-400: #4d4d4d;
    --gray-500: #5d5d5d;
    --gray-600: #8d8d8d;
    --gray-700: #adadad;
    --gray-800: #cdcdcd;
    
    background-color: #121212;
    color: #f8f9fa;
}

body.dark-mode .converter-section,
body.dark-mode .about-section,
body.dark-mode .converter-card {
    background-color: #1e1e1e;
    color: #f8f9fa;
}

body.dark-mode input,
body.dark-mode select {
    background-color: #2d2d2d;
    color: #f8f9fa;
    border-color: #3d3d3d;
}

body.dark-mode .conversion-table tr:nth-child(even) {
    background-color: #1a1a1a;
}

body.dark-mode .conversion-table tr:hover {
    background-color: #2d2d2d;
}

body.dark-mode h1, 
body.dark-mode h2, 
body.dark-mode h3, 
body.dark-mode h4, 
body.dark-mode h5, 
body.dark-mode h6 {
    color: #f8f9fa;
}

/* Loading indicator */
.loading {
    display: inline-block;
    position: relative;
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.loading:after {
    content: " ";
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    border-color: #fff transparent #fff transparent;
    animation: loading 1.2s linear infinite;
}

@keyframes loading {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tooltip styles */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 120px;
    background-color: var(--dark);
    color: #fff;
    text-align: center;
    border-radius: var(--radius-sm);
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}
