/* ===== Variables CSS ===== */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* ===== Header ===== */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

header p {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* ===== Main Content ===== */
main {
    padding: 30px;
}

/* ===== Type Selector ===== */
.type-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    justify-content: center;
}

.type-btn {
    padding: 15px 30px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    flex: 1;
    max-width: 200px;
}

.type-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.type-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== Upload Area ===== */
.upload-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.upload-box {
    flex: 1;
    min-width: 250px;
    max-width: 350px;
    border: 3px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background: var(--bg-color);
}

.upload-box:hover,
.upload-box.dragover {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
    transform: scale(1.02);
}

.upload-box.has-file {
    border-color: var(--secondary-color);
    background: rgba(16, 185, 129, 0.05);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-content .icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

.upload-content p {
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.file-name {
    display: block;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
    word-break: break-all;
}

.plus-icon {
    font-size: 2rem;
    color: var(--text-secondary);
    font-weight: bold;
}

/* ===== Preview Area ===== */
.preview-area {
    margin-bottom: 30px;
    display: none;
}

.preview-area.active {
    display: block;
}

.preview-area h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.preview-container {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.preview-item {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px;
    background: var(--card-bg);
    max-width: 200px;
}

.preview-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
}

.preview-item.pdf-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 150px;
    background: var(--bg-color);
    font-size: 3rem;
}

/* ===== Action Area ===== */
.action-area {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

.merge-btn,
.download-btn {
    padding: 15px 40px;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.merge-btn {
    background: var(--primary-color);
    color: white;
}

.merge-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.merge-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.download-btn {
    background: var(--secondary-color);
    color: white;
}

.download-btn:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* ===== History Section ===== */
.history-section {
    border-top: 2px solid var(--border-color);
    padding-top: 30px;
}

.history-section h3 {
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clear-btn {
    padding: 8px 16px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.clear-btn:hover {
    background: #dc2626;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: var(--radius);
    margin-bottom: 10px;
    transition: var(--transition);
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.history-icon {
    font-size: 2rem;
}

.history-info {
    flex: 1;
}

.history-info h4 {
    margin-bottom: 5px;
    color: var(--text-primary);
}

.history-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--border-color);
    border-radius: 5px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* ===== Notification ===== */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    background: var(--secondary-color);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transform: translateX(150%);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.notification.active {
    transform: translateX(0);
}

.notification.error {
    background: var(--danger-color);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .upload-area {
        flex-direction: column;
    }

    .plus-icon {
        transform: rotate(90deg);
    }

    .type-selector {
        flex-direction: column;
    }

    .type-btn {
        max-width: 100%;
    }

    .action-area {
        flex-direction: column;
    }

    header h1 {
        font-size: 1.5rem;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upload-box,
.history-item {
    animation: fadeIn 0.3s ease;
}

/* ===== Scrollbar ===== */
.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}