/* ===== CSS VARIABLES ===== */
:root {
    --primary-dark: #05386B;
    --primary-medium: #379683;
    --primary-light: #5CDB95;
    --secondary-light: #8EE4AF;
    --background-light: #EDF5E1;
    
    --shadow-dark: rgba(5, 56, 107, 0.3);
    --shadow-medium: rgba(55, 150, 131, 0.2);
    --shadow-light: rgba(92, 219, 149, 0.15);
    
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-raised: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== RESET AND BASE STYLES ===== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--background-light) 0%, #f8fdf6 100%);
    color: var(--primary-dark);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ===== TYPOGRAPHY ===== */
.app-title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-shadow: 2px 2px 4px var(--shadow-dark);
    margin-bottom: 0.5rem;
}

.app-subtitle {
    font-size: 1.2rem;
    color: var(--primary-medium);
    font-weight: 400;
    margin-bottom: 0;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.card-subtitle {
    color: var(--primary-medium);
    font-size: 0.95rem;
    margin-bottom: 0;
}

/* ===== HEADER SECTION ===== */
.header-section {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-medium) 100%);
    color: white;
    box-shadow: 0 4px 20px var(--shadow-dark);
    position: relative;
    overflow: hidden;
}

.header-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.05)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.header-section .app-title,
.header-section .app-subtitle {
    color: white;
    position: relative;
    z-index: 1;
}

/* ===== CONVERTER CARD ===== */
.converter-card {
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-raised);
    border: 1px solid rgba(55, 150, 131, 0.1);
    overflow: hidden;
    position: relative;
}

.converter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-light), var(--secondary-light));
}

.card-header {
    padding: 2rem 2rem 1rem;
    background: linear-gradient(135deg, #f8fdf6 0%, white 100%);
    border-bottom: 1px solid rgba(55, 150, 131, 0.1);
}

.card-body {
    padding: 2rem;
}

/* ===== FORM ELEMENTS ===== */
.form-label {
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.input-wrapper,
.select-wrapper {
    position: relative;
    display: block;
}

.input-field,
.select-field {
    background: white;
    border: 2px solid #e0e7e0;
    border-radius: var(--border-radius);
    padding: 0.875rem 1rem;
    font-size: 1rem;
    transition: var(--transition);
    box-shadow: var(--shadow-inset);
    position: relative;
    z-index: 2;
    width: 100%;
}

.input-field:focus,
.select-field:focus {
    border-color: var(--primary-light);
    box-shadow: 
        var(--shadow-inset),
        0 0 0 3px rgba(92, 219, 149, 0.2);
    outline: none;
    transform: translateY(-1px);
}

.input-shadow,
.select-shadow {
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    background: var(--shadow-light);
    border-radius: var(--border-radius);
    z-index: 1;
    transition: var(--transition);
}

.input-field:focus + .input-shadow,
.select-field:focus + .select-shadow {
    transform: translateY(2px);
    opacity: 0.5;
}

/* ===== CONVERT BUTTON ===== */
.btn-convert {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-light) 100%);
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: 
        0 4px 12px rgba(92, 219, 149, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-convert:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(92, 219, 149, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, var(--secondary-light) 0%, var(--primary-light) 100%);
}

.btn-convert:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 8px rgba(92, 219, 149, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-convert::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-convert:hover::before {
    left: 100%;
}

.btn-text {
    position: relative;
    z-index: 2;
}

/* ===== RESULT SECTION ===== */
.result-section {
    margin-top: 2rem;
    animation: slideInUp 0.5s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    background: linear-gradient(135deg, #f0f9f0 0%, white 100%);
    border: 2px solid var(--primary-light);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 
        var(--shadow-inset),
        0 4px 12px rgba(92, 219, 149, 0.1);
}

.result-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    text-align: center;
}

.result-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.result-from,
.result-to {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-inset);
    border: 1px solid rgba(92, 219, 149, 0.2);
    min-width: 120px;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.result-unit {
    font-size: 0.9rem;
    color: var(--primary-medium);
    font-weight: 500;
}

.result-arrow {
    color: var(--primary-light);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--shadow-inset);
    border: 2px solid var(--primary-light);
}

.result-details {
    text-align: center;
    font-size: 0.9rem;
    color: var(--primary-medium);
    padding: 1rem;
    background: rgba(92, 219, 149, 0.05);
    border-radius: var(--border-radius);
    border: 1px solid rgba(92, 219, 149, 0.1);
}

/* ===== QUICK CONVERSIONS ===== */
.quick-conversions {
    margin-top: 2rem;
}

.quick-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    text-align: center;
}

.quick-card {
    background: white;
    border: 1px solid rgba(55, 150, 131, 0.1);
    border-radius: var(--border-radius);
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    height: 100%;
}

.quick-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(92, 219, 149, 0.2);
    border-color: var(--primary-light);
}

.quick-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
}

.quick-from {
    font-weight: 600;
    color: var(--primary-dark);
}

.quick-arrow {
    color: var(--primary-light);
    font-weight: 700;
    font-size: 1.2rem;
}

.quick-to {
    font-weight: 600;
    color: var(--primary-medium);
}

/* ===== ALERTS ===== */
.alert-danger {
    background: linear-gradient(135deg, #ffe6e6 0%, #fff0f0 100%);
    border: 1px solid #ff9999;
    color: #cc0000;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-inset);
}

.invalid-feedback {
    display: block;
    font-size: 0.875rem;
    color: #cc0000;
    margin-top: 0.5rem;
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #ff9999;
    box-shadow: 
        var(--shadow-inset),
        0 0 0 3px rgba(255, 153, 153, 0.2);
}

/* ===== FOOTER ===== */
.footer-section {
    background: var(--primary-dark);
    color: white;
    margin-top: auto;
}

.footer-text {
    font-size: 0.9rem;
    opacity: 0.9;
}

.footer-link {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--secondary-light);
    text-decoration: underline;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .app-title {
        font-size: 2.5rem;
    }
    
    .app-subtitle {
        font-size: 1rem;
    }
    
    .card-body {
        padding: 1.5rem;
    }
    
    .card-header {
        padding: 1.5rem 1.5rem 1rem;
    }
    
    .result-content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .result-arrow {
        transform: rotate(90deg);
    }
    
    .quick-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .quick-arrow {
        transform: rotate(90deg);
    }
}

@media (max-width: 576px) {
    .app-title {
        font-size: 2rem;
    }
    
    .converter-card {
        margin: 0 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .btn-convert {
        padding: 0.875rem 2rem;
        font-size: 1rem;
    }
    
    .result-from,
    .result-to {
        min-width: 100px;
        padding: 0.75rem;
    }
    
    .result-value {
        font-size: 1.25rem;
    }
}

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

/* Focus visible for better keyboard navigation */
.btn-convert:focus-visible,
.quick-card:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-dark: #000000;
        --primary-medium: #333333;
        --primary-light: #006600;
        --secondary-light: #009900;
        --background-light: #ffffff;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-soft {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08) !important;
}

.border-gradient {
    border: 2px solid transparent;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, var(--primary-light), var(--secondary-light)) border-box;
}

/* ===== LOADING STATES ===== */
.btn-convert.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-convert.loading .btn-text::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
