@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap');

/* --- Theme Switcher --- */
.theme-switcher {
    position: absolute;
    top: 15px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

#themeLabel {
    font-weight: bold;
}

/* --- Base Styles --- */
body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 20px;
    transition: background-color 0.5s, color 0.5s;
}

/* --- Gradient & Glass Theme (Default) --- */
body[data-theme='gradient'] {
    color: #333;
}

body[data-theme='gradient'] .background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #ffafbd, #ffc3a0, #a0c4ff, #a0ffc3);
    background-size: 400% 400%;
    animation: gradient-animation 15s ease infinite;
    z-index: -1;
    overflow: hidden; /* Moved from body */
}

@keyframes gradient-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body[data-theme='gradient'] h1 { color: #ffffff; text-shadow: 2px 2px 4px rgba(0,0,0,0.5); }
body[data-theme='gradient'] .input-section, 
body[data-theme='gradient'] .output-section {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}
body[data-theme='gradient'] label { color: #222; }
body[data-theme='gradient'] input, 
body[data-theme='gradient'] select, 
body[data-theme='gradient'] button {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.8);
    color: #333;
}
body[data-theme='gradient'] button { background-color: #ff69b4; color: white; }
body[data-theme='gradient'] #outputContent h3 { color: #d13886; }

/* --- Dark Mode Theme --- */
body[data-theme='dark'] {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body[data-theme='dark'] h1 { color: #ffffff; }
body[data-theme='dark'] .input-section, 
body[data-theme='dark'] .output-section {
    background-color: #2a2a2a;
    border: 1px solid #444;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
body[data-theme='dark'] label { color: #bbb; }
body[data-theme='dark'] input, 
body[data-theme='dark'] select {
    background-color: #333;
    border: 1px solid #555;
    color: #e0e0e0;
}
body[data-theme='dark'] button { background-color: #00aaff; color: #ffffff; }
body[data-theme='dark'] .loader { border-top-color: #00aaff; }
body[data-theme='dark'] #outputContent h3 { color: #00aaff; }

/* General Body and Typography */
body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 10px 14px;
    background-color: #d0d0d0; /* Darker background for more contrast */
    color: #333;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center content horizontally */
    min-height: 100vh; /* Full viewport height */
}

/* Headings */
h1 {
    font-family: 'Google Sans', sans-serif;
    color: #20232a; /* Darker, more prominent heading */
    font-size: 1.8em; /* Reduced by ~15% from 2.125em */
    margin-bottom: 6px; /* Reduced by ~15% from 8px */
    text-align: center;
}

/* Main Container Layout */
.container {
    display: flex;
    gap: 14px; /* Reduced by ~15% from 17px */
    margin-top: 3px; /* Reduced by ~15% from 4px */
    max-width: 1200px; /* Max width for larger screens */
    width: 100%;
    box-sizing: border-box;
}

/* Common Section Styling to prevent overflow */
.input-section,
.output-section {
    box-sizing: border-box;
}

/* Section Styling (Input and Output) */
.input-section,
.output-section {
    background-color: #ffffff;
    padding: 21px;
    border-radius: 6px; /* Reduced by ~15% from 7px */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); /* Stronger, more pronounced shadow */
    transition: transform 0.2s ease-in-out; /* Smooth hover effect */
}

.input-section:hover,
.output-section:hover {
    transform: translateY(-3px); /* Lift effect on hover */
}

.input-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px; /* Reduced by ~15% from 7px */
}

.input-section label {
    font-weight: 600; /* Slightly bolder labels */
    margin-top: 3px; /* Reduced by ~15% from 4px */
    color: #555;
    display: flex;
    align-items: center;
    gap: 3px; /* Reduced by ~15% from 4px */
}

/* File icons styling */
.file-icon {
    height: 21px; /* Reduced by ~15% from 25px */
    vertical-align: middle;
}

/* Form Elements */
.input-section input[type="file"],
.input-section select {
    padding: 8px; /* Reduced by ~15% from 10px */
    border: 1px solid #e0e0e0; /* Lighter border */
    border-radius: 6px; /* Reduced by ~15% from 7px */
    background-color: #fdfdfd;
    font-size: 0.72em; /* Reduced by ~15% from 0.85em */
    color: #333;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.input-section input[type="file"]:focus,
.input-section select:focus {
    border-color: #61dafb; /* React blue on focus */
    box-shadow: 0 0 0 3px rgba(97, 218, 251, 0.3); /* Subtle glow */
    outline: none;
}

/* Button Styling */
.input-section button {
    padding: 7px 14px; /* Reduced by ~15% from 8px 17px */
    background-color: #61dafb; /* React blue */
    color: #20232a; /* Dark text on button */
    font-weight: bold;
    border: none;
    border-radius: 6px; /* Reduced by ~15% from 7px */
    cursor: pointer;
    margin-top: 7px; /* Reduced by ~15% from 8px */
    font-size: 0.76em; /* Reduced by ~15% from 0.9em */
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.input-section button:hover {
    background-color: #52c4e0; /* Slightly darker blue on hover */
    transform: translateY(-1px); /* Subtle lift */
}

.input-section button:active {
    transform: translateY(0); /* Press effect */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Loader (Spinner) Styling */
.loader {
    border: 5px solid #f3f3f3; /* Light grey */
    border-top: 5px solid #61dafb; /* React blue */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 10px; /* Space between spinner and text */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Output Section */
.output-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    align-items: center; /* Center content horizontally */
    text-align: center;
}

.output-section h2 {
    margin-bottom: 5px; /* Reduced margin further */
}

body[data-theme='gradient'] .output-section h2 { color: #20232a; }
body[data-theme='dark'] .output-section h2 { color: #ffffff; }

#outputContent {
    padding: 5px 10px; /* Reduced padding */
    min-height: 30px; /* Reduced min-height */
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #f0f0f0;
    color: #555;
    font-size: 0.75em; /* Adjusted font size */
    width: 100%;
    box-sizing: border-box;
    text-align: left;
}

#outputContent h3 {
    font-family: 'Google Sans', sans-serif;
    font-size: 1em; /* Reduced font size */
    margin-top: 5px; /* Reduced margin */
    margin-bottom: 3px; /* Reduced margin */
    border-bottom: 2px solid #61dafb;
    padding-bottom: 2px; /* Reduced padding */
}

#outputContent p {
    margin-left: 10px; /* Reduced margin */
    margin-bottom: 5px; /* Reduced margin */
    line-height: 1.4; /* Reduced line height */
}

body[data-theme='gradient'] #downloadLink {
    background-color: #d13886;
}

body[data-theme='dark'] #downloadLink {
    background-color: #00aaff;
}

#downloadLink {
    display: inline-block;
    margin-top: 3px; /* Reduced by ~15% from 4px */
    padding: 7px 14px; /* Reduced by ~15% from 8px 17px */
    color: white;
    text-decoration: none;
    border-radius: 6px; /* Reduced by ~15% from 7px */
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#downloadLink:hover {
    background-color: #45a049;
    transform: translateY(-1px);
}

#downloadLink:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Media Queries for Responsiveness */
@media (max-width: 992px) { /* Tablet and below */
    .container {
        flex-direction: column;
        gap: 20px;
    }

    .input-section,
    .output-section {
        width: 100%;
    }
}

@media (max-width: 576px) { /* Mobile phones */
    body {
        padding: 15px;
    }

    h1 {
        font-size: 1.8em;
    }

    .input-section,
    .output-section {
        padding: 15px;
    }

    .input-section button {
        font-size: 1em;
        padding: 12px 20px;
    }

    #downloadLink {
        padding: 10px 18px;
        font-size: 1em;
    }
}

/* Privacy Statement Styling */
.privacy-statement {
    margin-top: 7px; /* Reduced by ~15% from 8px */
    font-size: 0.61em; /* Reduced by ~15% from 0.72em */
    color: #777;
    text-align: center;
    max-width: 600px;
    padding: 10px; /* Reduced by ~15% from 12px */
    background-color: #f9f9f9;
    border-radius: 6px; /* Reduced by ~15% from 7px */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Instructions Button */
.instructions-button {
    padding: 6px 11px; /* Reduced by ~15% from 7px 13px */
    background-color: #007bff; /* Blue color for instructions */
    color: white;
    border: none;
    border-radius: 6px; /* Reduced by ~15% from 7px */
    cursor: pointer;
    margin-top: 3px; /* Reduced by ~15% from 4px */
    font-size: 0.65em; /* Reduced by ~15% from 0.76em */
    transition: background-color 0.2s ease-in-out;
}

.instructions-button:hover {
    background-color: #0056b3;
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.4); 
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    position: relative;
    animation-name: animatetop;
    animation-duration: 0.4s
}

/* Light/Gradient Theme Modal */
body[data-theme='gradient'] .modal-content {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #333;
}

body[data-theme='gradient'] .close-button {
    color: #555;
}

body[data-theme='gradient'] .close-button:hover,
body[data-theme='gradient'] .close-button:focus {
    color: #000;
}

/* Dark Theme Modal */
body[data-theme='dark'] .modal-content {
    background-color: #2c2c2c;
    border-color: #555;
    color: #e0e0e0;
}

body[data-theme='dark'] .close-button {
    color: #bbb;
}

body[data-theme='dark'] .close-button:hover,
body[data-theme='dark'] .close-button:focus {
    color: #fff;
}


/* Add Animation */
@keyframes animatetop {
    from {top: -300px; opacity: 0}
    to {top: 0; opacity: 1}
}

.close-button {
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 10px;
    transition: color 0.3s ease;
}

.close-button:hover,
.close-button:focus {
    text-decoration: none;
    cursor: pointer;
}