/* 圖片裁剪工具專屬樣式 */

/* Hero 區塊 */
.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-align: center;
    padding: 3rem 2rem;
    border-radius: var(--border-radius);
    margin: 2rem 0;
    box-shadow: 0 4px 20px var(--shadow-color);
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.95;
}

/* 上傳區塊 */
.upload-section {
    margin: 2rem 0;
}

.upload-container {
    border: 3px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--light-gray);
    transition: var(--transition);
    cursor: pointer;
}

.upload-container:hover,
.upload-container.dragover {
    border-color: var(--primary-color);
    background: rgba(247, 147, 26, 0.05);
    transform: translateY(-2px);
}

.upload-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.upload-content h3 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.upload-content p {
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 1.5rem;
}

.upload-hint {
    font-size: 0.9rem;
    opacity: 0.6;
    margin-top: 1rem;
}

/* 編輯區塊 */
.editor-section {
    margin: 2rem 0;
}

.editor-container {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    gap: 1.5rem;
    min-height: 600px;
}

/* 左側工具列 */
.toolbar {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 3px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
}

.toolbar h3 {
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.tool-group {
    margin-bottom: 1.5rem;
}

.tool-group label {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.tool-select,
.ratio-input {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: var(--transition);
    background: white;
}

.tool-select:focus,
.ratio-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.1);
}

.ratio-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ratio-input {
    width: calc(50% - 0.5rem);
}

.ratio-inputs span {
    font-weight: bold;
    color: var(--text-color);
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.tool-btn {
    flex: 1;
    padding: 0.7rem;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.3rem;
}

.tool-btn:hover {
    border-color: var(--primary-color);
    background: rgba(247, 147, 26, 0.1);
    transform: translateY(-2px);
}

.tool-btn:active {
    transform: translateY(0);
}

/* 中央編輯區域 */
.canvas-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.canvas-container {
    position: relative;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 3px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
    overflow: hidden;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas {
    display: block;
    max-width: 100%;
    max-height: 600px;
}

/* 裁剪框 */
.crop-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.crop-frame {
    position: absolute;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
    pointer-events: auto;
}

.crop-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px dashed rgba(255, 255, 255, 0.5);
}

/* 調整手柄 */
.resize-handle {
    position: absolute;
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    pointer-events: auto;
}

.resize-handle.nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.resize-handle.n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle.s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle.w {
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    cursor: w-resize;
}

.resize-handle.e {
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    cursor: e-resize;
}

/* 操作按鈕 */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* 右側預覽區 */
.preview-panel {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 3px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
}

.preview-panel h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.preview-container {
    background: var(--light-gray);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#previewCanvas {
    display: block;
    max-width: 100%;
    max-height: 250px;
    border-radius: 4px;
}

.preview-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--light-gray);
    border-radius: 6px;
}

.info-label {
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.9rem;
}

.info-value {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* 按鈕樣式 */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    background: var(--light-gray);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
}

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(247, 147, 26, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 1.2rem;
}

/* 功能特色 */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin: 3rem 0;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 3px 15px var(--shadow-color);
    text-align: center;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 25px var(--shadow-color);
}

.feature-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.feature-card h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.feature-card p {
    color: var(--text-color);
    opacity: 0.8;
    line-height: 1.6;
}

/* 使用教學 */
.tutorial {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    margin: 3rem 0;
    box-shadow: 0 3px 15px var(--shadow-color);
}

.tutorial h2 {
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.tutorial h3 {
    color: var(--text-color);
    margin: 2rem 0 1rem;
    font-size: 1.3rem;
}

.tutorial ol,
.tutorial ul {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.tutorial li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: var(--text-color);
}

.ratio-guide {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.ratio-item {
    background: var(--light-gray);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.ratio-item h4 {
    color: var(--text-color);
    margin-bottom: 0.75rem;
}

.ratio-item p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* FAQ */
.faq {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    margin: 3rem 0;
    box-shadow: 0 3px 15px var(--shadow-color);
}

.faq h2 {
    color: var(--text-color);
    margin-bottom: 2rem;
    font-size: 1.8rem;
}

.faq-item {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-item h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.faq-item p {
    color: var(--text-color);
    opacity: 0.85;
    line-height: 1.7;
}

.faq-item a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.faq-item a:hover {
    text-decoration: underline;
}

/* 工具資訊 */
.tool-info {
    text-align: center;
    padding: 2rem;
    background: var(--light-gray);
    border-radius: var(--border-radius);
    margin: 3rem 0;
}

.tool-info p {
    color: var(--text-color);
    line-height: 1.8;
}

.tool-info a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.tool-info a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* 響應式設計 */
@media (max-width: 1200px) {
    .editor-container {
        grid-template-columns: 220px 1fr 280px;
    }
}

@media (max-width: 992px) {
    .editor-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .toolbar,
    .preview-panel {
        order: 2;
    }

    .canvas-area {
        order: 1;
    }
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .features {
        grid-template-columns: 1fr;
    }

    .ratio-guide {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   暗色主題支援
   ============================================================================= */

[data-theme="dark"] .toolbar,
[data-theme="dark"] .canvas-container,
[data-theme="dark"] .preview-panel,
[data-theme="dark"] .feature-card,
[data-theme="dark"] .tutorial,
[data-theme="dark"] .faq {
    background: #1a1a1a;
    border-color: #333;
}

[data-theme="dark"] .upload-container {
    background: #1a1a1a;
    border-color: #333;
}

[data-theme="dark"] .upload-container:hover,
[data-theme="dark"] .upload-container.dragover {
    background: rgba(247, 147, 26, 0.1);
    border-color: var(--primary-color);
}

[data-theme="dark"] .tool-select,
[data-theme="dark"] .ratio-input {
    background: #2a2a2a;
    border-color: #444;
    color: #fff;
}

[data-theme="dark"] .tool-select:focus,
[data-theme="dark"] .ratio-input:focus {
    background: #2a2a2a;
    border-color: var(--primary-color);
}

[data-theme="dark"] .tool-btn {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .tool-btn:hover {
    background: rgba(247, 147, 26, 0.1);
    border-color: var(--primary-color);
}

[data-theme="dark"] .preview-container {
    background: #2a2a2a;
}

[data-theme="dark"] .info-item {
    background: #2a2a2a;
}

[data-theme="dark"] .btn {
    background: #2a2a2a;
    color: #fff;
    border-color: #444;
}

[data-theme="dark"] .btn:hover {
    background: #333;
}

[data-theme="dark"] .ratio-item {
    background: #1a1a1a;
    border-left-color: var(--primary-color);
}

[data-theme="dark"] .tool-info {
    background: #1a1a1a;
}
