/* ==================== CSS VARIABLES ==================== */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --success: #10b981;
    --error: #ef4444;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f9fafb;
    --white: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --input-bg: #ffffff;
    --input-border: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --success: #34d399;
    --error: #f87171;
    --text: #f3f4f6;
    --text-light: #9ca3af;
    --border: #374151;
    --bg: #1f2937;
    --white: #111827;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --input-bg: #374151;
    --input-border: #4b5563;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
}

/* ==================== GLOBAL RESET ==================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==================== BODY ==================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* ==================== THEME TOGGLE ==================== */

.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
    border-color: #4f46e5;
    background: #eef2ff;
}

.theme-icon {
    width: 24px;
    height: 24px;
    display: block;
    flex-shrink: 0;
    transition: transform 0.3s ease, fill 0.3s ease, stroke 0.3s ease;
}

.moon-icon {
    fill: #4b5563;
    stroke: none;
}

.sun-icon {
    display: none;
    fill: none;
    stroke: #FDB813;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle:hover .moon-icon {
    transform: rotate(20deg);
    fill: #4f46e5;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle:hover {
    border-color: #FDB813;
    background: #7c2d12;
}

[data-theme="dark"] .theme-toggle:hover .sun-icon {
    transform: rotate(20deg);
}

/* ==================== BACK BUTTON ==================== */

.back-button {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.back-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.back-button svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: none;
    stroke: var(--text);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s ease, stroke 0.3s ease;
}

.back-button:hover svg {
    transform: translateX(-3px);
    stroke: var(--primary);
}

/* ==================== LOADING OVERLAY ==================== */

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    min-width: 300px;
}

[data-theme="dark"] .loading-content {
    background: var(--white);
    color: var(--text);
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

[data-theme="dark"] .spinner {
    border-color: #374151;
    border-top-color: #818cf8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 1rem;
}

[data-theme="dark"] .progress-bar-container {
    background: #374151;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

[data-theme="dark"] .progress-text {
    color: var(--text-light);
}

/* ==================== FORM PAGE ==================== */

body.form-page {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-page .container {
    background: var(--white);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 500px;
    animation: fadeIn 0.3s ease-out;
}

@media (min-width: 1025px) {
    .form-page .container {
        resize: horizontal;
        overflow: auto;
        min-width: 400px;
        max-width: min(1400px, 95vw);
    }
}

.form-page h1 {
    margin-bottom: 2rem;
    color: var(--text);
    font-size: 1.875rem;
    font-weight: 700;
    text-align: center;
}

.function-description {
    background: var(--bg);
    margin-bottom: 2rem;
    border-radius: 6px;
    text-align: center;
}

.function-description p {
    color: var(--text-light);
    margin: 0;
    line-height: 1.6;
    white-space: pre-wrap;
}

[data-theme="dark"] .function-description p {
    color: #ffffff;
}

/* ==================== FORM FIELDS ==================== */

.field {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
    font-size: 0.875rem;
    text-transform: capitalize;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="time"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--white);
    color: var(--text);
}

input[type="date"],
input[type="time"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    font-family: inherit;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input.was-validated:invalid,
select.was-validated:invalid {
    border-color: var(--error);
}

input[type="number"] {
    color-scheme: light;
}

[data-theme="dark"] input[type="number"] {
    color-scheme: dark;
}

/* ==================== COLOR PICKER ==================== */

.color-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    position: relative;
}

.color-input-wrapper input[type="text"] {
    flex: 1;
}

.color-preview {
    width: 3rem;
    height: 2.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.color-preview:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.color-preview.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(50%);
}

.color-preview.disabled:hover {
    border-color: var(--border);
    box-shadow: none;
}

.color-picker-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

/* ==================== FILE INPUT ==================== */

input[type="file"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

input[type="file"]:hover {
    border-color: var(--primary);
    background: var(--white);
}

input[type="file"]:focus {
    outline: none;
    border-color: var(--primary);
    border-style: solid;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input[type="file"]::file-selector-button {
    padding: 0.5rem 1rem;
    margin-right: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
    background: var(--primary-dark);
}

/* ==================== CHECKBOX ==================== */

input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-field {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.checkbox-field:hover {
    background: var(--bg);
}

.checkbox-field label {
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* ==================== FIELD ERRORS ==================== */

.field-error {
    color: var(--error);
    font-size: 0.75rem;
    margin-top: 0.375rem;
    display: none;
    font-weight: 500;
}

/* ==================== OPTIONAL FIELDS ==================== */

.optional-toggle-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.optional-field input:disabled,
.optional-field select:disabled,
.optional-field textarea:disabled {
    background-color: var(--bg);
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==================== LIST FIELDS ==================== */

.list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-item-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.list-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.list-item input,
.list-item select {
    flex: 1;
    min-width: 0;
}

.list-item input[type="checkbox"] {
    flex: 0 0 auto;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
}

.list-item input[type="color"] {
    flex: 0 0 auto;
    width: 60px;
    height: 36px;
    padding: 2px;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.list-item input[type="color"]:hover {
    border-color: var(--primary);
}

.list-item input[type="color"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.list-item input[type="date"],
.list-item input[type="time"] {
    min-width: 140px;
}

.list-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    margin: 0;
    text-transform: none;
    letter-spacing: normal;
}

.list-btn-add {
    background: var(--primary);
    color: white;
}

.list-btn-add:hover {
    background: var(--primary-dark);
    transform: none;
    box-shadow: none;
}

.list-btn-remove {
    background: var(--error);
    color: white;
}

.list-btn-remove:hover {
    background: #dc2626;
    transform: none;
    box-shadow: none;
}

.list-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.list-btn:disabled:hover {
    transform: none;
}

.list-item-error {
    color: var(--error);
    font-size: 0.75rem;
    font-weight: 500;
    display: none;
    padding-left: 0.25rem;
    animation: slideIn 0.2s ease-out;
}

.list-item input.was-validated:invalid {
    border-color: var(--error);
}

/* ==================== BUTTONS ==================== */

button {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

button:active {
    transform: translateY(0);
}

button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==================== RESULTS & ERRORS ==================== */

#result {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #ecfdf5;
    border: 2px solid #10b981;
    border-radius: 8px;
    display: none;
    animation: slideIn 0.3s ease-out;
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
}

[data-theme="dark"] #result {
    background: #064e3b;
    border-color: #34d399;
}

#result img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 0.5rem;
}

#error {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fef2f2;
    border: 2px solid var(--error);
    border-radius: 8px;
    display: none;
    color: #991b1b;
    animation: slideIn 0.3s ease-out;
}

[data-theme="dark"] #error {
    background: #7f1d1d;
    border-color: #f87171;
    color: #fca5a5;
}

pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
    color: #065f46;
}

[data-theme="dark"] pre {
    color: #6ee7b7;
}

/* ==================== TOAST ==================== */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--success);
    color: var(--white);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 10000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== COPY BUTTON ==================== */

.result-json-container {
    position: relative;
    background: var(--bg);
    border-radius: 8px;
    overflow: hidden;
}

.result-json-container pre {
    padding: 0.85rem 3rem 1rem 1rem;
    margin: 0;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
    color: var(--success);
    line-height: 1.5;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    font-size: 0;
    background: transparent;
    color: var(--text-light);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: none;
}

.copy-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary);
    border-color: var(--border);
    transform: none;
    box-shadow: none;
}

[data-theme="dark"] .copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-light);
    border-color: var(--border);
}

.copy-btn svg {
    display: block;
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.copy-btn:active {
    transform: scale(0.95);
}

/* ==================== FILE DOWNLOAD ==================== */

.file-download,
.files-download {
    margin-top: 1rem;
}

.files-download h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

.file-download {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.file-download:last-child {
    margin-bottom: 0;
}

.file-download .file-name {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-download button {
    width: auto;
    padding: 0.5rem 1.5rem;
    margin: 0;
    font-size: 0.875rem;
    text-transform: none;
    letter-spacing: normal;
    flex-shrink: 0;
}

.file-download button:hover {
    transform: none;
    box-shadow: none;
}

/* ==================== INDEX PAGE ==================== */

body.index-page {
    padding: 2rem 1rem;
}

.index-page .container {
    max-width: 900px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease-out;
    padding-top: 1rem;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.tool-card {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 150px;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.tool-card:hover::before {
    transform: scaleX(1);
}

.tool-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0;
}

.tool-arrow {
    margin-top: auto;
    padding-top: 1rem;
    color: var(--primary);
    font-size: 1.5rem;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}

.tool-card:hover .tool-arrow {
    opacity: 1;
    transform: translateX(0);
}

.empty-state {
    background: var(--white);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: var(--text-light);
    font-size: 1rem;
}

/* ==================== ANIMATIONS ==================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== MULTIPLE OUTPUTS ==================== */

.multiple-outputs {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.output-item {
    padding: 1rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
}

.output-item:first-child {
    margin-top: 0;
}

.output-item img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0;
}

.output-item pre {
    margin: 0;
}

.output-item .file-download,
.output-item .files-download {
    margin: 0;
    border: none;
    background: transparent;
    padding: 0;
}

.output-item .files-download h3 {
    margin-bottom: 0.75rem;
}

/* ==================== TABLE RESULTS ==================== */

.result-table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg);
}

.result-table-container::-webkit-scrollbar {
    height: 8px;
}

.result-table-container::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

.result-table-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.result-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.result-table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
}

.result-table thead {
    background: var(--primary);
    color: white;
}

.result-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.result-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.result-table tbody tr:last-child {
    border-bottom: none;
}

.result-table tbody tr:nth-child(odd) {
    background: #f3f4f6;
}

.result-table td {
    padding: 0.75rem 1rem;
    color: var(--text);
    white-space: nowrap;
}

[data-theme="dark"] .result-table thead {
    background: var(--primary-dark);
}

[data-theme="dark"] .result-table tbody tr:nth-child(odd) {
    background: rgba(129, 140, 248, 0.1);
}

/* ==================== HEADER ACTIONS (Logout + Theme) ==================== */

.header-actions {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.75rem;
    z-index: 1000;
}

.header-actions .theme-toggle {
    position: static; 
    margin: 0;
}

.logout-button {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-decoration: none;
    color: var(--text-light);
    padding: 0;
}

.logout-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
    border-color: var(--error);
    color: var(--error);
    background: #fef2f2;
}

[data-theme="dark"] .logout-button:hover {
    background: #450a0a;
    border-color: #f87171;
}

.logout-button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Ajuste Responsive para móviles */
@media (max-width: 640px) {
    .header-actions {
        top: 0.75rem;
        right: 0.75rem;
        gap: 0.5rem;
    }

    .logout-button {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .logout-button svg {
        width: 18px;
        height: 18px;
    }
}

/* ==================== LOGIN PAGE ==================== */

body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--white);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.4s ease-out;
    border: 1px solid transparent;
}

[data-theme="dark"] .login-card {
    border-color: var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.95rem;
}

.login-card .form-group {
    margin-bottom: 1.5rem;
}

.login-card label {
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: 500;
    font-size: 0.9rem;
}

.login-card input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text);
    transition: all 0.2s ease;
}

.login-card input:focus {
    background: var(--white);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.btn-login {
    width: 100%;
    padding: 0.875rem;
    margin-top: 1rem;
    background: var(--primary);
    color: white;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s;
}

.btn-login:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(1px);
}

.error-banner {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 1024px) {
    body.form-page {
        padding: 0.5rem;
    }
    
    .form-page .container {
        padding: 1.5rem;
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .theme-toggle,
    .back-button {
        top: 0.75rem;
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .back-button {
        left: 0.75rem;
    }
    
    .theme-toggle {
        right: 0.75rem;
    }
    
    .theme-icon,
    .back-button svg {
        width: 20px;
        height: 20px;
    }

    body.form-page {
        padding: 0.5rem;
    }
    
    .form-page .container {
        padding: 1.5rem;
    }
    
    .form-page h1 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .field {
        margin-bottom: 1.25rem;
    }
    
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="tel"],
    input[type="date"],
    input[type="time"],
    input[type="file"],
    select {
        font-size: 16px;
    }
    
    button {
        padding: 0.875rem;
    }
    
    body.index-page {
        padding: 1.5rem 0.75rem;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .tool-card {
        padding: 1.5rem;
    }
    
    .list-item {
        flex-wrap: wrap;
    }
    
    .list-item input[type="date"],
    .list-item input[type="time"] {
        min-width: 120px;
    }
    
    .list-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .file-download {
        flex-direction: column;
        align-items: stretch;
    }
    
    .file-download .file-name {
        text-align: center;
        white-space: normal;
    }
    
    .file-download button {
        width: 100%;
    }
    
    .multiple-outputs {
        gap: 1rem;
    }
    
    .output-item {
        padding: 0.75rem;
    }
    
    .result-table {
        font-size: 0.75rem;
    }
    
    .result-table th,
    .result-table td {
        padding: 0.5rem 0.75rem;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    body.form-page {
        padding: 0.5rem 1rem;
    }
    
    .form-page .container {
        padding: 1rem;
    }
    
    .form-page h1 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .field {
        margin-bottom: 1rem;
    }
}

@media (min-width: 640px) and (max-width: 1024px) {
    .form-page .container {
        max-width: 100%;
    }
    
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    body {
        background: white;
    }
    
    .loading-overlay,
    button,
    .list-btn,
    .toggle-switch,
    .theme-toggle,
    .back-button {
        display: none !important;
    }
    
    .form-page .container {
        box-shadow: none;
        max-width: 100%;
    }
}

/* ==================== TOOL GROUPS ==================== */

.groups-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.group-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.group-card:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 2;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 2rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

.group-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.group-card.open .group-header::before {
    opacity: 1;
}

.group-header:hover {
    background: var(--bg);
}

.group-card.open .group-header {
    background: var(--bg);
}

.group-title {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.group-count {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.group-chevron {
    width: 24px;
    height: 24px;
    stroke: var(--text-light);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.group-card.open .group-chevron {
    transform: rotate(180deg);
    stroke: var(--primary);
}

.group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    position: relative;
    z-index: 1;
}

.group-card.open .group-content {
    max-height: 5000px;
}

.group-content .tools-grid {
    padding: 0.5rem 2rem 2rem 2rem;
    margin-bottom: 0;
}

.group-content .tool-card {
    min-height: 120px;
    position: relative;
    z-index: 1;
}

.group-content .tool-card:hover {
    z-index: 5;
}

@media (max-width: 640px) {
    .group-header {
        padding: 1.25rem 1.5rem;
        gap: 0.75rem;
    }
    
    .group-title {
        font-size: 1.125rem;
    }
    
    .group-count {
        min-width: 1.75rem;
        height: 1.75rem;
        font-size: 0.8125rem;
    }
    
    .group-chevron {
        width: 20px;
        height: 20px;
    }
    
    .group-content .tools-grid {
        padding: 0.5rem 1.5rem 1.5rem 1.5rem;
    }
}

@media (min-width: 640px) and (max-width: 1024px) {
    .group-content .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==================== FILE LIST ===================== */

.file-list {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg);
}

.file-list::-webkit-scrollbar {
    width: 6px;
}

.file-list::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.file-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    flex-shrink: 0;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.file-remove-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    margin: 0;
    width: auto;
    height: auto;
    text-transform: none;
    flex-shrink: 0;
}

.file-remove-btn:hover {
    color: #dc2626;
    transform: none;
    box-shadow: none;
}

/* ==================== FILE INPUT WRAPPER ==================== */

.file-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.file-input-wrapper .file-input {
    flex: 1;
    margin: 0;
}

.file-input-wrapper .add-more-files-btn {
    width: 40px;
    min-width: 40px;
    padding: 0;
    margin: 0;
    background: transparent;
    color: var(--text-light);
    border: none;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-input-wrapper .add-more-files-btn:hover {
    background: transparent;
    color: var(--primary);
    transform: scale(1.2);
    box-shadow: none;
}

.file-input-wrapper .add-more-files-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: transparent;
    color: var(--text-light);
}

.file-input-wrapper .add-more-files-btn:disabled:hover {
    background: transparent;
    color: var(--text-light);
    transform: none;
}