/* ============================================
   Miwnix Tech — Tools Shared Styles
   Shared across PDF2IMAGE, IMAGE_CONVERTER, IMAGE_COMPRESSOR
   ============================================ */



* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* --- Background Animation (Canvas) --- */
#canvas-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    /* Placeholder for potential JS bg */
    background: radial-gradient(circle at top right, rgba(0, 242, 255, 0.1), transparent 40%),
        radial-gradient(circle at bottom left, rgba(189, 0, 255, 0.1), transparent 40%);
}

/* --- Header --- */
header {
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    color: var(--primary);
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--primary);
}

/* --- Main Content --- */
main {
    flex: 1;
    padding: 40px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 40px;
    line-height: 1.5;
    max-width: 600px;
}

/* --- Upload Area --- */
.upload-area {
    width: 100%;
    max-width: 800px;
    background: var(--bg-card);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(0, 242, 255, 0.05);
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.1);
}

.upload-icon {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    transition: var(--transition);
}

.upload-area:hover .upload-icon {
    color: var(--primary);
    transform: scale(1.1);
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
}

#pdf-input,
#file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* --- Controls --- */
.controls {
    width: 100%;
    max-width: 800px;
    margin-top: 30px;
    background: var(--bg-card);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    display: none;
    /* Hidden by default */
    animation: fadeIn 0.5s ease;
}

.control-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}

.control-group {
    flex: 1;
    min-width: 200px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

select,
input[type="number"] {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

select:focus,
input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}

/* Quality slider (Compressor) */
.quality-value {
    color: var(--primary);
    font-weight: 700;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

/* Size badge (Converter/Compressor) */
.size-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-family: 'Share Tech Mono', monospace;
    z-index: 3;
    pointer-events: none;
}

.size-badge.smaller {
    background: rgba(0, 200, 100, 0.25);
    color: #00e070;
    border: 1px solid rgba(0, 200, 100, 0.3);
}

.size-badge.larger {
    background: rgba(255, 80, 80, 0.25);
    color: #ff6060;
    border: 1px solid rgba(255, 80, 80, 0.3);
}

.btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1rem;
    width: 100%;
}

.btn:hover {
    background: var(--primary);
    color: black;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}

.btn:disabled {
    border-color: #555;
    color: #555;
    cursor: not-allowed;
    background: transparent;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    border: none;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(189, 0, 255, 0.4);
}

/* --- Status Bar --- */
#status-bar {
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
    padding: 15px;
    border-radius: 10px;
    background: rgba(0, 242, 255, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    text-align: center;
    font-family: 'Share Tech Mono', monospace;
    display: none;
    animation: fadeIn 0.5s ease;
}

/* --- Output Grid --- */
#output-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    margin-top: 40px;
    padding: 0 20px;
}

.image-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.image-card:hover {
    transform: translateY(-5px);
    border-color: var(--secondary);
    box-shadow: 0 5px 20px rgba(189, 0, 255, 0.2);
}

.image-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.25);
}

.image-card img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}

/* Card checkbox */
.card-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    width: 22px;
    height: 22px;
    accent-color: var(--primary);
    cursor: pointer;
    filter: brightness(1.2);
}

/* Zoom button overlay */
.card-zoom {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    font-size: 0.85rem;
}

.image-card:hover .card-zoom {
    opacity: 1;
}

.card-zoom:hover {
    background: var(--primary);
    color: #000;
}

.image-info {
    padding: 10px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Share Tech Mono', monospace;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Selection toolbar */
.selection-toolbar {
    width: 100%;
    max-width: 1200px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-top: 25px;
    padding: 15px 20px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.4s ease;
}

.selection-toolbar .toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.selection-toolbar .toolbar-left label {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    user-select: none;
}

.selection-toolbar .toolbar-left input[type='checkbox'] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.selected-count {
    font-family: 'Share Tech Mono', monospace;
    color: var(--primary);
    font-size: 0.9rem;
}

.toolbar-right {
    display: flex;
    gap: 10px;
}

.toolbar-right .btn {
    width: auto;
    padding: 10px 20px;
    font-size: 0.85rem;
}

/* Lightbox modal */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
    cursor: zoom-out;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 95vw;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0, 242, 255, 0.2);
    cursor: default;
    animation: popIn 0.3s ease;
}

.lightbox-info {
    margin-top: 15px;
    color: var(--text-muted);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 25px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.lightbox-close:hover {
    background: #ff4444;
    border-color: #ff4444;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.lightbox-nav:hover {
    background: var(--primary);
    color: #000;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Footer --- */
footer {
    margin-top: auto;
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

/* --- Responsive Design --- */

/* Tablet & Mobile (Max 1024px) */
@media (max-width: 1024px) {
    h1 {
        font-size: 2.2rem;
    }

    /* Center Header & Footer */
    header .container {
        flex-direction: column;
        gap: 15px;
    }

    .logo,
    .back-link {
        justify-content: center;
        width: 100%;
        text-align: center;
    }

    /* Container max width for Tablet */
    .container {
        width: 90%;
    }

    #output-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

/* Mobile Only (Max 768px) */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    .control-row {
        flex-direction: column;
        gap: 15px;
    }

    .control-group {
        width: 100%;
    }

    #output-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }

    /* Full width container for Mobile */
    .container {
        width: 100%;
        padding: 0 20px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .selection-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-right {
        flex-direction: column;
    }

    .toolbar-right .btn {
        width: 100%;
    }
}

/* --- JSON Formatter Specific Styles --- */
.json-editor-container {
    width: 100%;
    max-width: 800px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    overflow: hidden;
    margin-top: 20px;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-small:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 242, 255, 0.1);
}

#json-input,
#json-output {
    width: 100%;
    min-height: 300px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: #fff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

#json-output {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
}

.status-message {
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

.status-message.success {
    background: rgba(0, 200, 100, 0.1);
    border: 1px solid rgba(0, 200, 100, 0.3);
    color: #00e070;
}

.status-message.error {
    background: rgba(255, 80, 80, 0.1);
    border: 1px solid rgba(255, 80, 80, 0.3);
    color: #ff6060;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 12px 18px;
    color: white;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    border-color: #00e070;
}

.toast-error {
    border-color: #ff6060;
}

.toast i {
    font-size: 1.1rem;
}

.toast-success i {
    color: #00e070;
}

.toast-error i {
    color: #ff6060;
}

/* --- Color Palette Generator Styles --- */
#palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    width: 100%;
}

.color-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    animation: popIn 0.5s ease;
}

.color-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 5px 20px rgba(0, 242, 255, 0.2);
}

.color-swatch {
    width: 100%;
    height: 100px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.color-swatch::after {
    content: '\f0c5';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.5rem;
    opacity: 0;
    transition: var(--transition);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.color-swatch:hover::after {
    opacity: 1;
}

.color-info {
    padding: 12px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
}

.color-hex {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.color-rgb {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    #palette-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 15px;
    }
}

/* --- QR Generator Styles --- */
.qr-input-container {
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
}

.qr-input-container label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.qr-input-container input[type="text"] {
    width: 100%;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.qr-input-container input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

input[type="color"] {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

/* --- Markdown Editor Styles --- */
.markdown-toolbar {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.markdown-split-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    margin-top: 20px;
}

.markdown-panel {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

.panel-header {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

#markdown-input {
    flex: 1;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: #fff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.markdown-preview {
    flex: 1;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    overflow-y: auto;
    color: #fff;
    line-height: 1.8;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary);
}

.markdown-preview h1 {
    font-size: 2rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.markdown-preview h2 {
    font-size: 1.5rem;
}

.markdown-preview code {
    background: rgba(0, 242, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Share Tech Mono', monospace;
    color: var(--primary);
}

.markdown-preview pre {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-preview pre code {
    background: none;
    padding: 0;
}

.markdown-preview blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 15px;
    color: var(--text-muted);
    margin: 15px 0;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.markdown-preview a {
    color: var(--primary);
    text-decoration: none;
}

.markdown-preview a:hover {
    text-decoration: underline;
}

@media (max-width: 1024px) {
    .markdown-split-view {
        grid-template-columns: 1fr;
    }
}

/* --- Responsive Design --- */