/* ==========================================================================
   Image to Base64 Tool – Fully Responsive with Day/Night Mode
   ========================================================================== */

/* Import fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

/* ====================== MAIN STYLES ====================== */

.base64-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    font-family: 'Poppins', sans-serif;
}

.base64-wrapper {
    max-width: 920px;
    margin: 0 auto;
}

.base64-title {
    font-size: 2.8rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.4rem;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
}

.base64-icon {
    font-size: 2.6rem;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.base64-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    line-height: 1.5;
}

.base64-card {
    background: var(--surface);
    border-radius: var(--radius, 16px);
    border: 1px solid var(--border);
    padding: 2.2rem;
    box-shadow: var(--shadow);
}

/* Tabs */
.base64-tabs {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 2.2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.base64-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.75rem 2.2rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 0.95rem;
}

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

.base64-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Sections */
.base64-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.base64-section.active {
    display: block;
}

.section-title {
    font-size: 1.9rem;
    text-align: center;
    margin: 0 0 1.8rem;
    color: var(--text);
}

.section-title .highlight {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* File Upload Area */
.file-label {
    display: block;
    margin-bottom: 0.7rem;
    color: var(--text-light);
    font-weight: 500;
}

.file-input-wrapper {
    position: relative;
}

#image-upload {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-btn {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 3rem 1.5rem;
    text-align: center;
    background: var(--bg);
    transition: all 0.25s ease;
    cursor: pointer;
}

.file-btn:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.04);
}

.upload-icon {
    font-size: 2.6rem;
    margin-bottom: 0.8rem;
    color: var(--primary);
}

/* Image Preview */
.preview-area {
    margin: 1.5rem 0;
    text-align: center;
}

.image-preview {
    max-width: 100%;
    max-height: 320px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    background: repeating-conic-gradient(#f8f9fa 0% 25%, transparent 0% 50%) 50% / 40px 40px;
    display: none;
    object-fit: contain;
}

/* Textarea & Result */
.base64-textarea {
    width: 100%;
    min-height: 160px;
    padding: 1.1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    resize: vertical;
    transition: all 0.25s;
}

.base64-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.result-label {
    display: block;
    margin-bottom: 0.7rem;
    color: var(--text-light);
    font-weight: 500;
    font-size: 1.05rem;
}

.result-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.3rem;
    min-height: 100px;
    font-family: 'Courier New', monospace;
    color: var(--primary);
    font-weight: 500;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 240px;
    overflow-y: auto;
}

/* Actions */
.base64-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 2.5rem;
}

.base64-btn {
    padding: 0.85rem 1.8rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.25s;
    font-size: 0.95rem;
}

.base64-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

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

.download-btn {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white !important;
    border-color: #10b981 !important;
}

.download-btn:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    transform: translateY(-2px);
}

/* Loading Overlay */
.base64-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.base64-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Download Card Container */
.download-card-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 1rem;
}

.download-card {
    width: 520px;
    max-width: 100%;
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border-radius: 24px;
    padding: 2.2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.18);
    position: relative;
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dark-mode .download-card {
    background: linear-gradient(135deg, #1e1e2e, #2d2d44);
    border: 1px solid rgba(99, 102, 241, 0.35);
}

.download-card-bg-decoration {
    position: absolute;
    top: -80px;
    right: -80px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
}

.download-card-corner-decoration {
    position: absolute;
    bottom: -40px;
    left: -40px;
    width: 140px;
    height: 140px;
    background: conic-gradient(from 90deg at 50% 50%, var(--primary), transparent 120deg);
    opacity: 0.07;
    border-radius: 50%;
}

.download-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.8rem;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.download-logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.download-logo-icon {
    font-size: 1.8rem;
}

.download-logo-text {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.download-date {
    color: var(--text-light);
    font-size: 0.95rem;
}

.download-mode {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.4rem;
    text-align: center;
}

.download-input-label {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 0.4rem;
}

.download-input {
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: 1.6rem;
    word-break: break-all;
    background: var(--bg);
    padding: 0.5rem;
    border-radius: 8px;
}

.download-preview-wrapper {
    text-align: center;
    margin: 1.6rem 0;
}

.download-preview {
    max-width: 100%;
    max-height: 220px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    object-fit: contain;
}

.download-result-box {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: white;
    padding: 1.6rem;
    border-radius: 16px;
    text-align: center;
    margin: 1.8rem 0;
}

.download-result-label {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 0.6rem;
    display: block;
}

.download-result-value {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.5;
    max-height: 180px;
    overflow: hidden;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-all;
}

.download-card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 2rem;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Presets / Funfact / SEO */
.base64-presets,
.base64-funfact,
.base64-seo {
    margin-top: 3rem;
    text-align: center;
}

.base64-presets h3,
.base64-funfact {
    color: var(--text);
    margin-bottom: 1.2rem;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    justify-content: center;
}

.preset-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.7rem 1.4rem;
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

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

.info-btn {
    background: var(--surface);
    color: var(--text-light);
    cursor: default;
}

.info-btn:hover {
    transform: none;
    border-color: var(--border);
}

.base64-funfact {
    font-size: 1.05rem;
    color: var(--text-light);
    padding: 1.2rem 2rem;
    background: rgba(99, 102, 241, 0.04);
    border-radius: 16px;
    border: 1px solid rgba(99, 102, 241, 0.12);
}

/* SEO Section */
.base64-seo h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.base64-seo h3 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    color: var(--primary);
}

.base64-seo p {
    color: var(--text-light);
    line-height: 1.7;
    margin-bottom: 1rem;
}

.base64-features-list {
    list-style: none;
    padding: 0;
    text-align: left;
    max-width: 680px;
    margin: 1.5rem auto;
}

.base64-features-list li {
    margin: 0.9rem 0;
    padding-left: 1.8rem;
    position: relative;
    color: var(--text-light);
}

.base64-features-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
}

.base64-howto-list {
    list-style: none;
    counter-reset: step;
    padding: 0;
    text-align: left;
    max-width: 680px;
    margin: 1.5rem auto;
}

.base64-howto-list li {
    counter-increment: step;
    margin-bottom: 1rem;
    padding-left: 2rem;
    position: relative;
    color: var(--text-light);
}

.base64-howto-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

/* ====================== RESPONSIVE DESIGN ====================== */

/* Tablet Styles (768px to 1024px) */
@media screen and (max-width: 1024px) {
    .base64-container {
        padding: 0 1.5rem;
        margin: 1.5rem auto;
    }

    .base64-title {
        font-size: 2.5rem;
    }

    .base64-icon {
        font-size: 2.3rem;
    }

    .base64-card {
        padding: 1.8rem;
    }

    .section-title {
        font-size: 1.7rem;
    }
}

/* Mobile Landscape & Tablet Portrait (481px to 768px) */
@media screen and (max-width: 768px) {
    .base64-container {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    .base64-title {
        font-size: 2rem;
    }

    .base64-icon {
        font-size: 1.8rem;
    }

    .base64-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .base64-card {
        padding: 1.2rem;
    }

    .base64-tabs {
        gap: 0.4rem;
    }

    .base64-tab {
        padding: 0.6rem 1.5rem;
        font-size: 0.85rem;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 1.2rem;
    }

    .file-btn {
        padding: 2rem 1rem;
    }

    .upload-icon {
        font-size: 2.2rem;
    }

    .image-preview {
        max-height: 250px;
    }

    .base64-textarea {
        min-height: 120px;
        font-size: 0.95rem;
        padding: 0.8rem;
    }

    .result-box {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .base64-actions {
        gap: 0.8rem;
        margin-top: 2rem;
    }

    .base64-btn {
        padding: 0.7rem 1.4rem;
        font-size: 0.85rem;
    }

    .download-card {
        width: 90%;
        padding: 1.5rem;
    }

    .download-mode {
        font-size: 1.2rem;
    }

    .download-result-value {
        font-size: 0.85rem;
    }

    .preset-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .base64-funfact {
        font-size: 0.9rem;
        padding: 1rem;
    }

    .base64-seo h2 {
        font-size: 1.5rem;
    }

    .base64-seo h3 {
        font-size: 1.2rem;
    }
}

/* Mobile Portrait (up to 480px) */
@media screen and (max-width: 480px) {
    .base64-container {
        padding: 0 0.75rem;
        margin: 0.75rem auto;
    }

    .base64-title {
        font-size: 1.5rem;
    }

    .base64-icon {
        font-size: 1.3rem;
    }

    .base64-subtitle {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }

    .base64-card {
        padding: 1rem;
        border-radius: 12px;
    }

    .base64-tabs {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .base64-tab {
        width: 100%;
        text-align: center;
        padding: 0.6rem;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .file-btn {
        padding: 1.5rem 0.75rem;
    }

    .upload-icon {
        font-size: 1.8rem;
    }

    .file-btn p {
        font-size: 0.8rem;
    }

    .image-preview {
        max-height: 200px;
    }

    .base64-textarea {
        min-height: 100px;
        font-size: 0.85rem;
        padding: 0.7rem;
    }

    .result-label {
        font-size: 0.9rem;
    }

    .result-box {
        padding: 0.8rem;
        font-size: 0.8rem;
        max-height: 180px;
    }

    /* Make buttons stack in 2 columns */
    .base64-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .base64-btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
        width: 100%;
        text-align: center;
    }

    .download-card {
        padding: 1rem;
    }

    .download-card-header {
        flex-direction: column;
        text-align: center;
    }

    .download-mode {
        font-size: 1rem;
    }

    .download-input {
        font-size: 0.85rem;
    }

    .download-result-value {
        font-size: 0.75rem;
        max-height: 120px;
    }

    .preset-buttons {
        gap: 0.6rem;
    }

    .preset-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }

    .base64-funfact {
        font-size: 0.8rem;
        padding: 0.8rem;
    }

    .base64-seo h2 {
        font-size: 1.2rem;
    }

    .base64-seo h3 {
        font-size: 1rem;
    }

    .base64-seo p,
    .base64-features-list li,
    .base64-howto-list li {
        font-size: 0.85rem;
    }

    .base64-howto-list li {
        padding-left: 1.8rem;
    }

    .base64-howto-list li::before {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }
}

/* Extra Small Devices (up to 360px) */
@media screen and (max-width: 360px) {
    .base64-title {
        font-size: 1.3rem;
    }

    .base64-icon {
        font-size: 1.1rem;
    }

    .section-title {
        font-size: 1rem;
    }

    .base64-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
    }

    .preset-btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.7rem;
    }
}

/* Touch-friendly improvements for mobile devices */
@media (hover: none) and (pointer: coarse) {
    .base64-tab,
    .base64-btn,
    .preset-btn,
    .file-btn {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .base64-btn:active,
    .preset-btn:active {
        transform: scale(0.98);
    }
}

/* Loading overlay responsiveness */
@media screen and (max-width: 768px) {
    .base64-spinner {
        width: 40px;
        height: 40px;
    }

    .base64-loading p {
        font-size: 0.9rem;
    }
}

/* Print styles */
@media print {
    .base64-tabs,
    .base64-actions,
    .preset-buttons,
    .base64-funfact {
        display: none;
    }

    .base64-container {
        padding: 0;
        margin: 0;
    }

    .base64-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Smooth transitions */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

/* Dark mode adjustments */
.dark-mode .base64-card,
.dark-mode .result-box,
.dark-mode .file-btn {
    background: var(--surface);
}

.dark-mode .base64-textarea {
    background: var(--bg);
    color: var(--text);
}

.dark-mode .download-card {
    background: linear-gradient(135deg, #1e1e2e, #2d2d44);
}

/* Scrollbar styling */
.base64-textarea::-webkit-scrollbar,
.result-box::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.base64-textarea::-webkit-scrollbar-track,
.result-box::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 4px;
}

.base64-textarea::-webkit-scrollbar-thumb,
.result-box::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.base64-textarea::-webkit-scrollbar-thumb:hover,
.result-box::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark, #4f46e5);
}