/* Buttons & Dropdowns */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
    user-select: none;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn.btn-primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
}

.btn.btn-primary:hover:not(:disabled) {
    background-color: var(--btn-primary-hover-bg);
}

.btn.btn-secondary {
    background-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border-color: var(--surface-border);
    box-shadow: 0 1px 2px 0 var(--btn-secondary-shadow-color);
}

.btn.btn-secondary:hover:not(:disabled) {
    background-color: var(--btn-secondary-hover-bg);
}

.btn.btn-secondary.active, .btn.btn-secondary.active:hover:not(:disabled) {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border-color: var(--btn-primary-bg);
    box-shadow: none;
}

.btn.btn-icon {
    padding: 0.5rem;
    background-color: transparent;
    color: var(--text-muted);
}

.btn.btn-icon:hover:not(:disabled) {
    background-color: var(--btn-secondary-hover-bg);
    color: var(--text);
}

.btn.btn-danger {
    background-color: var(--btn-danger-bg);
    color: var(--btn-danger-text);
}

.btn.btn-danger:hover:not(:disabled) {
    background-color: var(--btn-danger-hover-bg);
}

.user-menu-btn {
    gap: 0.5rem;
    font-weight: 600;
}

.dropdown-container {
    position: relative;
}

.split-button-container {
    display: flex;
    transition: transform 0.2s ease-in-out;
}

.split-button-container:hover {
    transform: translateY(-1px);
}

#main-save-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    gap: 0.5rem;
}

#save-options-toggle-btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    border-left: 1px solid var(--btn-primary-hover-bg);
}

body.dark #save-options-toggle-btn {
    border-left-color: rgba(0, 0, 0, 0.25);
}

.split-button-container:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 0.375rem;
    transform: translateY(0);
}

.split-button-container .btn:focus-visible {
    outline: none !important;
}

.dropdown-item:hover {
    background-color: var(--bg-alt);
}

#save-options-toggle-btn {
    background: var(--btn-primary-bg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background-color: var(--surface-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--surface-border);
    box-shadow: var(--surface-shadow);
    z-index: 110;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text);
    text-align: left;
    background: none;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--header-border);
    margin: 0.5rem 0;
}

.moon-icon { display: none; }
.sun-icon { display: block; }
body.dark .moon-icon { display: block; }
body.dark .sun-icon { display: none; }


/* Modals */
.modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: var(--modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden; /* Hide from interaction/autofill */
    pointer-events: none;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.modal.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--surface-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--surface-shadow);
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s;
    transform: scale(0.95);
}

.modal.visible .modal-content {
    transform: scale(1);
}

.modal-content h2, .modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.modal-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.modal-description a {
    color: var(--accent);
    text-decoration: none;
}

.modal-description a:hover {
    text-decoration: underline;
}

.modal-description code {
    background-color: var(--code-bg);
    color: var(--text);
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    border-radius: 3px;
    font-family: 'Fira Code', monospace;
}

.modal-content input[type="text"], .modal-content input[type="password"], .modal-content select {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.875rem;
    background-color: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--surface-border);
    border-radius: 0.375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-content input:focus, .modal-content select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--focus-ring-color);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.modal-url {
    font-size: 0.95em;
    background-color: var(--code-bg);
    color: var(--accent);
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    white-space: nowrap;
    font-family: monospace;
    margin-bottom: 20px;
}


/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    box-shadow: var(--surface-shadow);
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    min-width: 250px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.toast.toast-success {
    background-color: var(--toast-success-bg);
    color: var(--toast-success-text);
}

.toast.toast-error {
    background-color: var(--toast-error-bg);
    color: var(--toast-error-text);
}

/* Loading Modal */
.loading-modal {
    display: none;
    z-index: 2100;
}

.loading-modal.visible {
    display: flex;
}

.spinner-box {
    background: transparent;
    box-shadow: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    color: var(--highlight);
}

.loader-container {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinning-circle {
    width: 100%;
    height: 100%;
    position: absolute;
    animation: spin 1.5s cubic-bezier(0.6, 0, 0.4, 1) infinite;
}

.pulsing-logo {
    width: 75%;
    height: auto;
    position: absolute;
    z-index: 10;
    animation: pulse 2.5s ease-in-out infinite;
}

.loader-text {
    font-size: 1.2em;
    font-weight: 500;
    text-align: center;
    opacity: 0.9;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
}

.loader-timer {
    margin-top: 1rem;
    font-size: 1rem;
    font-family: 'Fira Code', monospace;
    color: var(--text-muted);
    font-weight: 500;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(0.95);
        opacity: 0.9;
    }
}

/* Form Controls */
.hg-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    background-color: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--surface-border);
    border-radius: 0.375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

.hg-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--focus-ring-color);
}

/* File Type Badge */
.file-type-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 0.75rem;
    color: #fff;
    text-transform: uppercase;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.type-json { background-color: #4f46e5; }
.type-pdf { background-color: #ef4444; }
.type-png, .type-jpeg, .type-jpg, .type-bmp, .type-gif, .type-svg { background-color: #22c55e; }
.type-eml { background-color: #64748b; }
.type-html { background-color: #0891b2; }
.type-unknown { background-color: #f97316; }

/* Progress Modal */
.progress-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s;
}

.progress-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-step.pending {
    color: var(--text-muted);
}
.progress-step.pending .progress-icon::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--surface-border);
}

.progress-step.in-progress {
    color: var(--text);
}
.progress-step.in-progress .progress-icon::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

.progress-step.success {
    color: var(--success-text);
}
.progress-step.success .progress-icon {
    color: var(--success);
}
.progress-step.success .progress-icon::before {
    content: '✓';
    font-size: 1.5rem;
    font-weight: bold;
}

.progress-step.error {
    color: var(--danger-text);
}
.progress-step.error .progress-icon {
    color: var(--danger);
}
.progress-step.error .progress-icon::before {
    content: '×';
    font-size: 1.75rem;
    font-weight: bold;
}