/* --- Safi Brand Palette --- */
:root {
    --safi-green: #77c385; /* Matched to your logo icon */
    --safi-green-dark: #5fa66b;
    --safi-dark: #2d2d2d; /* Matched to your logo text */
    --safi-bg: #f8faf9;
    --border-color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--safi-bg);
    color: var(--safi-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.text-center { text-align: center; }

/* --- Layout Wrapper --- */
.app-wrapper {
    width: 100%;
    max-width: 750px;
    margin-top: 20px;
}

header img {
    margin-bottom: 10px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
}

header p {
    color: #666;
    margin-bottom: 30px;
    font-size: 1rem;
    letter-spacing: 0.5px;
}
/* --- Tab Navigation: Optimized for All Screens --- */
.tool-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 25px;
}

.tab {
    text-decoration: none;
    color: #555;
    background-color: #fff;
    padding: 10px 15px;
    border-radius: 12px; /* Slightly less rounded for a tighter grid look */
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Specific Mobile Optimization (Phones) --- */
@media (max-width: 480px) {
    .tool-tabs {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* Forces exactly 2 columns */
        gap: 8px;
        padding: 0 5px;
    }

    .tab {
        padding: 12px 8px; /* Taller touch targets for thumbs */
        font-size: 0.75rem; /* Slightly smaller text to prevent overlapping */
        border-radius: 8px;
        line-height: 1.2;
        height: 100%; /* Ensures all boxes in a row are same height */
    }
}

/* --- Specific Tablet Optimization --- */
@media (min-width: 481px) and (max-width: 768px) {
    .tool-tabs {
        grid-template-columns: repeat(3, 1fr); /* 3 columns for tablets */
        display: grid;
    }
}

/* --- The Main Converter Card --- */
.converter-card {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.02);
}

@media (max-width: 600px) {
    .converter-card {
        padding: 25px 15px;
    }
}

/* --- Form Inputs --- */
input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 15px;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--safi-green);
    box-shadow: 0 0 0 3px rgba(119, 195, 133, 0.2);
}

/* --- Upload Form --- */
.file-drop-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    border: 2px dashed #cbd5e0;
    border-radius: 12px;
    background-color: #fdfdfd;
    transition: 0.3s ease;
}

.file-drop-area:hover { 
    background-color: #f2f9f4; 
    border-color: var(--safi-green);
}

.file-msg {
    font-weight: 500;
    margin-bottom: 15px;
    color: var(--safi-dark);
}

.file-input {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    cursor: pointer;
    opacity: 0; 
}

.btn-browse {
    background-color: #f1f3f5;
    color: var(--safi-dark);
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: bold;
    pointer-events: none; 
}

/* --- Action Buttons (Safi Green) --- */
.btn-convert {
    background-color: var(--safi-green);
    color: white;
    border: none;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
}

.btn-convert:hover { 
    background-color: var(--safi-green-dark);
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(119, 195, 133, 0.3);
}

/* --- Progress Bar --- */
.progress-track {
    width: 100%;
    height: 12px;
    background-color: #edf2f7;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 15px;
}

.progress-fill {
    height: 100%;
    background-color: var(--safi-green);
    width: 0%;
    transition: width 0.4s ease;
}

/* --- Alerts --- */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    text-align: center;
}

.alert-success { background-color: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background-color: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* --- AdSense Containers --- */
.ad-container {
    width: 100%;
    min-height: 90px;
    background-color: #f1f3f5;
    border: 1px solid #eee;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    border-radius: 8px;
    font-size: 0.7rem;
    color: #999;
}

/* --- Image Resizer UI (New Hooks) --- */
.resizer-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.ratio-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    transition: 0.2s;
}

.ratio-btn:hover { background: #f2f9f4; border-color: var(--safi-green); }
.ratio-btn.active { background: var(--safi-green); color: white; border-color: var(--safi-green); }

.preview-canvas-container {
    width: 100%;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    margin-bottom: 20px;
}

/* --- Footer --- */
footer {
    margin-top: 60px;
    padding-bottom: 40px;
    color: #999;
    font-size: 0.9rem;
}

.footer-links {
    margin-top: 10px;
}

.footer-links a {
    color: var(--safi-green-dark);
    text-decoration: none;
    margin: 0 10px;
    font-weight: 500;
}

.footer-links a:hover {
    text-decoration: underline;
}



/* --- SEO Content Block --- */
.seo-section {
    margin-top: 50px;
    padding-top: 40px;
    border-top: 1px solid #e2e8f0;
    color: #4a5568;
}

.seo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    text-align: left;
}

.seo-item h3 {
    font-size: 1.1rem;
    color: var(--safi-dark);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.seo-item p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #718096;
}

@media (max-width: 600px) {
    .seo-grid {
        grid-template-columns: 1fr;
    }
}

/* --- SEO Section Link Styling --- */
.seo-item h3 a {
    color: var(--safi-dark);
    text-decoration: none;
    transition: color 0.2s ease;
}

.seo-item h3 a:hover {
    color: var(--safi-green-dark);
}

.seo-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--safi-green);
    text-decoration: none;
    transition: color 0.2s ease;
}

.seo-link:hover {
    color: var(--safi-green-dark);
    text-decoration: underline;
}