:root {
    --primary-color: #5d50ff;
    --text-color: #333;
    --bg-light: #f4f6f9;
    --border-color: #ddd;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --error-color: #d9534f;
    --success-color: #5cb85c;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    max-width: 800px;
}

.header h1 {
    font-size: 2.5em;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.header p {
    color: #666;
}

/* Tool Selection Layout - Handles 5 items */
.tool-selection-container.five-tools {
    display: flex;
    gap: 10px; 
    width: 100%;
    max-width: 900px;
    margin-bottom: 30px;
}

.tool-selector {
    flex: 1;
    padding: 15px 10px; /* Reduced padding for 5 items */
    background-color: #fff;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: var(--shadow);
}

.tool-selector:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.tool-selector.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(93, 80, 255, 0.3);
}

.tool-selector h2 {
    color: var(--primary-color);
    margin-bottom: 5px;
    font-size: 1.1em; /* Reduced font size for 5 items */
}

.tool-selector .supports {
    font-size: 0.8em;
    color: #999;
}

/* Main Content Area */
.tool-content-area {
    width: 100%;
    max-width: 900px;
    background-color: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
    min-height: 400px; 
}

.tool-content.hidden {
    display: none;
}

.upload-box {
    border: 3px dashed #c0c0ff;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background-color: #f8f8ff;
    margin-bottom: 20px;
    cursor: pointer;
}

.upload-box input[type="file"] {
    display: none;
}

.upload-box label {
    display: block;
    cursor: pointer;
    font-size: 1.1em;
    color: #666;
    font-weight: bold;
}

.upload-icon {
    display: block;
    font-size: 3em;
    margin-bottom: 10px;
}

/* Tool Actions & Buttons */
.tool-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.tool-actions input[type="text"] {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #4a3ecf;
}

.btn-primary:disabled, .btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #eee;
    color: var(--text-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: #ddd;
}

/* Image Preview List and Item Styles */
.image-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    min-height: 100px;
    padding: 10px;
    border: 1px dashed #f0f0f0;
    border-radius: 6px;
    background-color: #fafafa;
    align-items: center;
}

.placeholder-preview {
    margin: auto;
    color: #999;
    padding: 20px;
}

.image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
    background-color: white;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-name {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.6em;
    padding: 2px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 1;
    font-size: 12px;
    cursor: pointer;
    z-index: 10;
}


/* Compression Details (Image Compressor only) */
.compression-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 20px;
}

.size-detail p {
    font-size: 1.1em;
    margin: 5px 0;
}

.size-detail span {
    font-weight: bold;
    color: var(--primary-color);
}

.compression-options {
    text-align: right;
    width: 50%;
}

.compression-options label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    text-align: left;
}

/* Status Message */
.status-message {
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 6px;
    font-weight: bold;
    display: none;
    text-align: center;
    max-width: 900px;
    width: 100%;
}

.status-message.error {
    background-color: #f2dede;
    color: var(--error-color);
    border: 1px solid #ebccd1;
}

.status-message.success {
    background-color: #dff0d8;
    color: var(--success-color);
    border: 1px solid #d6e9c6;
}

/* Responsiveness */
@media (max-width: 768px) {
    .tool-selection-container.five-tools {
        flex-wrap: wrap; /* Allow wrapping */
        gap: 8px;
    }
    .tool-selector {
        flex-basis: calc(50% - 4px); /* Two items per row */
        padding: 10px;
    }
    .tool-selector h2 {
        font-size: 1em;
    }
    .tool-actions {
        flex-direction: column;
        gap: 10px;
    }
    .tool-actions button, .tool-actions input {
        width: 100%;
    }
}
