/* Base Styles */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --error-color: #e63946;
    --success-color: #2a9d8f;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #f8f9fa;
    --white: #ffffff;
    --border-color: #e0e0e0;
    --border-radius: 12px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
    --primary-rgba-10: rgba(67, 97, 238, 0.1);
    --primary-rgba-05: rgba(67, 97, 238, 0.05);
    --primary-rgba-2: rgba(67, 97, 238, 0.2);
    --primary-rgba-3: rgba(67, 97, 238, 0.3);
    --primary-rgba-8: rgba(67, 97, 238, 0.8);
}

/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    background-image: radial-gradient(circle, #f8f9fa, #e9ecef);
}

.container { max-width: 1200px; margin: 0 auto; padding: 40px 20px; position: relative; }

header { text-align: center; margin-bottom: 40px; }
.logo-container { display: flex; justify-content: center; }
.logo { display: block; transition: transform 0.3s ease; }
.logo:hover { transform: scale(1.1); }
header h1 { font-size: clamp(1.8rem, 5vw, 2.5rem); margin-bottom: 10px; color: black; }
header p { font-size: clamp(0.9rem, 2vw, 1.1rem); color: var(--text-light); }

/* Loading Overlay */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease;
}
.loading-overlay.active { opacity: 1; visibility: visible; }
.loading-content { text-align: center; padding: 30px; border-radius: var(--border-radius); background-color: var(--white); box-shadow: var(--shadow-md); width: 300px; }
.spinner { width: 40px; height: 40px; margin: 0 auto; border: 4px solid var(--primary-rgba-10); border-left-color: var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Error Message */
.error-message { border-radius: var(--border-radius); padding: 20px; margin-bottom: 30px; display: none; background-color: rgba(230, 57, 70, 0.1); border: 1px solid var(--error-color); }
.error-content { display: flex; align-items: center; gap: 15px; }
.error-content p { flex-grow: 1; color: var(--error-color); font-weight: 500; }

/* Upload Area */
.upload-area { background-color: var(--white); border: 2px dashed var(--border-color); border-radius: var(--border-radius); padding: 40px; text-align: center; margin-bottom: 40px; transition: var(--transition); cursor: pointer; }
.upload-area:hover { border-color: var(--primary-color); box-shadow: 0 0 15px var(--primary-rgba-2); }
.upload-inner img { margin-bottom: 20px; animation: bounce 2s infinite ease-in-out; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.file-input-label { display: inline-block; background-color: var(--primary-color); color: var(--white); padding: 12px 24px; border-radius: 50px; margin: 15px 0; font-weight: 500; cursor: pointer; transition: var(--transition); }
.file-input-label:hover { background-color: var(--secondary-color); transform: translateY(-2px); }

/* Preview & Ratio Selector */
.preview-container { display: none; margin-bottom: 40px; }
.preview-wrapper { display: flex; flex-direction: column; gap: 20px; }
@media (min-width: 768px) { .preview-wrapper { flex-direction: row; } .image-preview { flex: 2; } .preview-info { flex: 1; } }

.image-preview { display: flex; align-items: center; justify-content: center; background-color: var(--white); border-radius: var(--border-radius); overflow: hidden; box-shadow: var(--shadow-sm); }
#preview-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

.info-card { background-color: var(--white); border-radius: var(--border-radius); padding: 20px; box-shadow: var(--shadow-sm); }

/* NEW Ratio Selector Styles */
.ratio-selector { margin: 15px 0; padding: 15px 0; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); }
.ratio-selector p { font-weight: 600; font-size: 0.85rem; margin-bottom: 10px; }
.radio-group { display: flex; gap: 10px; }
.radio-label { flex: 1; cursor: pointer; }
.radio-label input { display: none; }
.radio-label span { display: block; padding: 10px; border: 2px solid var(--border-color); border-radius: 8px; text-align: center; font-size: 0.85rem; font-weight: 600; transition: var(--transition); }
.radio-label input:checked + span { border-color: var(--primary-color); background-color: var(--primary-rgba-05); color: var(--primary-color); }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
button { cursor: pointer; padding: 12px 24px; border: none; border-radius: 50px; font-weight: 500; font-size: 1rem; transition: var(--transition); }
.primary-btn { background-color: var(--primary-color); color: var(--white); }
.secondary-btn { background-color: var(--white); border: 1px solid var(--border-color); color: var(--text-color); }

/* Result Section */
.result-container { display: none; margin-bottom: 40px; }
.slices-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; margin-bottom: 30px; }
.slice-item { position: relative; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-sm); transition: var(--transition); background-color: var(--white); }
.slice-item img { width: 100%; height: auto; display: block; }
.slice-label, .slice-number { position: absolute; top: 10px; left: 10px; background-color: var(--primary-rgba-8); color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px; }
.resolution { position: absolute; bottom: 10px; right: 10px; background-color: rgba(0, 0, 0, 0.6); color: white; padding: 4px 8px; border-radius: 4px; font-size: 11px; }

/* Footer */
footer { margin-top: 60px; text-align: center; color: var(--text-light); padding: 20px 0; border-top: 1px solid var(--border-color); }
.footer-content { display: flex; flex-direction: column; align-items: center; gap: 15px; }
@media (min-width: 768px) { .footer-content { flex-direction: row; justify-content: space-between; } }