/* CSS Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content */
main {
    padding: 2rem;
}

/* Calculator Sections */
.calculator-section {
    margin-bottom: 3rem;
    padding: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.calculator-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: left 0.5s ease;
}

.calculator-section:hover::before {
    left: 0;
}

.calculator-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.calculator-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.calculator-section:hover h2 {
    color: #667eea;
}

/* Input Groups */
.input-group {
    margin-bottom: 1rem;
}

.input-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.input-row .input-group {
    flex: 1;
    min-width: 200px;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.3s ease;
    position: relative;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

input[type="text"].error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
    animation: shake 0.5s ease-in-out;
}

input[type="text"].valid {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

input[type="text"].loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

/* Status icons */
.input-status {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.input-group.valid .input-status {
    opacity: 1;
    color: #28a745;
}

.input-group.error .input-status {
    opacity: 1;
    color: #e74c3c;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

small {
    display: block;
    color: #666;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Output Groups */
.output-group {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.output-item {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.output-item label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    display: block;
}

output {
    display: block;
    padding: 0.75rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: monospace;
    min-height: 2.5rem;
    word-break: break-all;
    transition: all 0.3s ease;
    position: relative;
}

output:not(:empty) {
    background: #f8f9fa;
    border-color: #28a745;
}

output:empty {
    background: #fff;
    border-color: #ddd;
}

/* Copy button for outputs */
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.output-item:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: #5a67d8;
}

.copy-btn.copied {
    background: #28a745;
}

/* Info Section */
.info-section {
    background: #e8f4f8;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.info-section h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #333;
}

.info-section ul {
    margin-bottom: 1rem;
}

.info-section li {
    margin-bottom: 0.5rem;
}

.info-section p {
    font-style: italic;
    color: #666;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

/* Responsive Design */

/* Tablet */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 1.5rem;
    }

    header h1 {
        font-size: 2rem;
    }

    main {
        padding: 1rem;
    }

    .input-row {
        flex-direction: column;
    }

    .output-group {
        flex-direction: column;
        gap: 1rem;
    }

    .output-item {
        min-width: auto;
    }
}

/* Mobile */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }

    header p {
        font-size: 1rem;
    }

    .calculator-section {
        padding: 1rem;
    }

    .calculator-section h2 {
        font-size: 1.3rem;
    }

    input[type="text"] {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    output {
        padding: 0.6rem;
        font-size: 0.9rem;
        min-height: 2rem;
    }

    .info-section {
        padding: 1rem;
    }
}

/* Large Desktop */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }

    header h1 {
        font-size: 3rem;
    }

    main {
        padding: 3rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .calculator-section {
        border-width: 2px;
    }

    input[type="text"] {
        border-width: 3px;
    }

    output {
        border-width: 2px;
    }
}