/* --- Base and Variables --- */
:root {
    --primary-color: #4a90e2;
    --primary-hover: #357ABD;
    --secondary-color: #50e3c2;
    --background-color: #f7f9fc;
    --card-bg-color: #ffffff;
    --text-color: #333;
    --light-text-color: #888;
    --border-color: #e0e0e0;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --border-radius: 12px;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 2rem 1rem;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--card-bg-color);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

h1, h2 {
    color: #1a2a45;
}

h1 {
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

h1 .fa-wand-magic-sparkles {
    margin-right: 10px;
    color: var(--primary-color);
}


.main-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.action-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover:not(:disabled) {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.action-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.editor-area {
    width: 100%;
    margin-bottom: 25px;
    background-color: #f0f0f0;
    border: 1px dashed #ccc;
    min-height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-container {
    max-width: 100%;
    max-height: 500px;
}

#image-preview {
    max-width: 100%;
    max-height: 500px;
    display: block;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.feature-card {
    background: #fdfdfd;
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--border-radius);
}

.full-width-card {
    grid-column: 1 / -1; /* Make this card span full width */
    text-align: center;
}

.feature-card h2 {
    margin-top: 0;
    font-size: 1.2rem;
}

.feature-card button {
    background-color: #5a67d8;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-right: 10px;
    margin-top: 5px;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.feature-card button:hover {
    background-color: #434190;
}

.feature-card input[type="number"], .feature-card select {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
    margin-right: 10px;
    margin-top: 5px;
}

#quality-control {
    margin-top: 15px;
}

/* --- Modal Styles (For GIF Maker) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: var(--card-bg-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 700px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--light-text-color);
}

/* --- Styles from your MAKEGIF project --- */
.modal-content header {
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.modal-content header h1 {
    color: var(--primary-color);
}

.upload-container {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: background-color 0.3s, border-color 0.3s;
}

.upload-container label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
}

.upload-container .fa-cloud-arrow-up {
    font-size: 3rem;
    color: var(--primary-color);
}

.upload-container span {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--light-text-color);
}

.upload-container:hover, .upload-container.drag-over {
    background-color: #e9f3ff;
    border-color: var(--primary-color);
}

#image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    min-height: 110px;
}

.preview-item {
    position: relative;
    width: 100px;
    cursor: grab;
    transition: transform 0.2s;
}
.preview-item.dragging {
    opacity: 0.5;
    transform: scale(1.05);
}

.preview-item-image-wrapper {
    position: relative;
    width: 100px;
    height: 56.25px; /* 16:9 ratio */
    border-radius: 8px;
    overflow: hidden;
    background-color: #eee;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item-dimensions {
    font-size: 11px;
    text-align: center;
    color: var(--light-text-color);
    margin-top: 4px;
    font-weight: 500;
}

.remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.preview-item-image-wrapper:hover .remove-btn {
    opacity: 1;
}

.settings-card {
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.settings-card h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}
.settings {
    display: flex;
    justify-content: center;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
}

.setting-item label {
    font-weight: 500;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setting-item input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100px;
    text-align: center;
}

.controls {
    text-align: center;
    margin-bottom: 1rem;
}

.button, .controls button {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.8rem 1.8rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.button:hover, .controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

#status-area {
    text-align: center;
    min-height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

#gif-output img {
    max-width: 100%;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    box-shadow: var(--shadow);
}

.loader {
    width: 25px;
    height: 25px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- 首頁樣式 --- */
.landing-page {
    text-align: center;
    padding-top: 50px;
}
.tool-selection {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 40px;
    flex-wrap: wrap;
}
.tool-link {
    display: block;
    width: 300px;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    background-color: #fff;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}
.tool-link:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}
.tool-link h2 {
    color: var(--primary-color);
}

/* --- 影片工具頁面樣式 --- */
.main-nav {
    text-align: center;
    margin-bottom: 20px;
}
.main-nav a {
    text-decoration: none;
    color: var(--primary-hover);
    font-weight: 500;
}
.tool-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}
.tool-card h2 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}
.tool-card .controls {
    margin: 15px 0;
}
.tool-card video {
    background: #f0f0f0;
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
    border-radius: 8px;
}
.tool-card .setting-item {
    margin: 10px 0;
}
#status, #result {
    margin-top: 15px;
    font-weight: 500;
}