/* PicTools - CSS Styles */

/* CSS Variables for theming */
:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --accent: #0d6efd;
    --accent-hover: #0b5ed7;
    --accent-light: #e7f1ff;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --drop-zone-bg: #f1f5f9;
    --drop-zone-border: #cbd5e1;
    --code-bg: #f1f3f5;
    --checkered: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Crect width='10' height='10' fill='%23ddd'/%3E%3Crect x='10' y='10' width='10' height='10' fill='%23ddd'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --text-muted: #6b7280;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #1e3a5f;
    --border: #374151;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.4);
    --drop-zone-bg: #1e293b;
    --drop-zone-border: #475569;
    --code-bg: #1e293b;
    --checkered: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Crect width='10' height='10' fill='%23333'/%3E%3Crect x='10' y='10' width='10' height='10' fill='%23333'/%3E%3C/svg%3E");
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

/* Header */
.header {
    background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
    color: white;
    padding: 40px 0;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-icon {
    font-size: 3rem;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

.tagline {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Navigation */
.tool-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px var(--shadow);
}

.nav-scroll {
    display: flex;
    gap: 5px;
    padding: 15px 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.nav-scroll::-webkit-scrollbar {
    height: 4px;
}

.nav-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

/* Main Content */
.main-content {
    padding: 30px 0;
}

/* Ad Banners */
.ad-banner {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin: 20px 0;
}

.ad-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.ad-placeholder {
    color: var(--text-secondary);
}

.ad-placeholder a {
    color: var(--accent);
}

/* Tool Sections */
.tool-section {
    display: none;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 30px;
    margin: 20px 0;
    box-shadow: 0 4px 20px var(--shadow);
}

.tool-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.tool-header {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.tool-header h2 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.tool-header p {
    color: var(--text-secondary);
}

.premium-badge {
    display: inline-block;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #000;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 10px;
}

/* Drop Zone */
.drop-zone {
    border: 3px dashed var(--drop-zone-border);
    border-radius: 16px;
    background: var(--drop-zone-bg);
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 15px;
}

.drop-zone p {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.drop-hint {
    color: var(--text-muted);
    font-size: 0.9rem !important;
}

/* Tool Options */
.tool-options {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 25px 0;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
}

.option-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.option-group input[type="text"],
.option-group input[type="number"],
.option-group select,
.option-group textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}

.option-group input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.option-group input[type="checkbox"] {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
}

.option-group input[type="color"] {
    width: 50px;
    height: 35px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

/* Format Buttons */
.format-buttons {
    display: flex;
    gap: 8px;
}

.format-btn {
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.format-btn:hover {
    border-color: var(--accent);
}

.format-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Position Grid (Watermark) */
.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    width: 120px;
}

.pos-btn {
    width: 35px;
    height: 35px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.pos-btn:hover {
    background: var(--bg-tertiary);
}

.pos-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Preview Area */
.preview-area {
    margin: 25px 0;
}

.before-after {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .before-after {
        grid-template-columns: 1fr;
    }
}

.preview-box {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 15px;
}

.preview-box.full-width {
    grid-column: 1 / -1;
}

.preview-box h4 {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.preview-image {
    min-height: 200px;
    max-height: 400px;
    background: var(--bg-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.preview-image.large {
    min-height: 300px;
}

.preview-image.checkered {
    background-image: var(--checkered);
}

.preview-image img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.file-info {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Output Area */
.output-area,
.input-area {
    margin: 20px 0;
}

.output-area label,
.input-area label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.output-area textarea,
.input-area textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    resize: vertical;
}

/* Code Output */
.code-output {
    margin: 20px 0;
    padding: 20px;
    background: var(--code-bg);
    border-radius: 12px;
}

.code-output label {
    font-weight: 600;
    margin-bottom: 10px;
    display: block;
}

.code-output pre {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-premium {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #000;
    font-size: 1.2rem;
    padding: 15px 40px;
}

.btn-premium:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(255, 140, 0, 0.3);
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 5px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
}

/* Batch Results */
.batch-results {
    margin-top: 20px;
}

.batch-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 10px;
}

.batch-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
}

.batch-item-info {
    flex: 1;
}

.batch-item-name {
    font-weight: 500;
}

.batch-item-size {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.batch-item-savings {
    color: var(--success);
    font-weight: 600;
}

/* Favicon Grid */
.favicon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.favicon-item {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.favicon-item img {
    max-width: 100%;
    margin-bottom: 10px;
    background-image: var(--checkered);
}

.favicon-item span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Color Picker */
.color-picker-area {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

@media (max-width: 900px) {
    .color-picker-area {
        grid-template-columns: 1fr;
    }
}

.picker-canvas-container {
    position: relative;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
}

#picker-canvas {
    max-width: 100%;
    cursor: crosshair;
    display: block;
}

.color-magnifier {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 3px solid white;
    border-radius: 50%;
    pointer-events: none;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background-size: 500%;
}

.color-info-panel {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 20px;
}

.current-color {
    margin-bottom: 20px;
}

.color-swatch {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
}

.color-value {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.color-value label {
    width: 40px;
    font-weight: 600;
    font-size: 0.85rem;
}

.color-value input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: monospace;
}

.copy-btn {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    cursor: pointer;
}

.palette-section {
    margin-top: 20px;
}

.palette-section h4 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.palette-color {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.palette-color:hover {
    transform: scale(1.1);
    border-color: var(--text-primary);
}

/* Cropper */
.cropper-area {
    margin: 20px 0;
}

.crop-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
}

#crop-image {
    max-width: 100%;
    display: block;
}

.crop-overlay {
    position: absolute;
    inset: 0;
    display: none;
}

.crop-box {
    position: absolute;
    border: 2px solid var(--accent);
    background: rgba(13, 110, 253, 0.1);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle.n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle.s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle.e { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }
.crop-handle.w { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }

.crop-info {
    text-align: center;
    padding: 10px;
    color: var(--text-secondary);
}

/* Premium CTA */
.premium-cta {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 60px 0;
    text-align: center;
}

.premium-cta h2 {
    font-size: 2rem;
    margin-bottom: 40px;
}

.premium-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.feature {
    padding: 20px;
}

.feature-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 15px;
}

.feature h4 {
    margin-bottom: 8px;
}

.feature p {
    color: #b0b3b8;
    font-size: 0.9rem;
}

/* Affiliate Section */
.affiliate-section {
    background: var(--bg-secondary);
    padding: 50px 0;
}

.affiliate-section h3 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-secondary);
}

.affiliate-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.affiliate-card {
    display: block;
    padding: 25px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.affiliate-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow-lg);
}

.affiliate-card span {
    font-size: 2rem;
    display: block;
    margin-bottom: 10px;
}

.affiliate-card h4 {
    color: var(--text-primary);
    margin-bottom: 5px;
}

.affiliate-card p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 50px 0 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section h4 {
    margin-bottom: 15px;
}

.footer-section p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 10px;
}

.footer-section a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-section a:hover {
    color: var(--accent);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 15px 20px;
    margin-top: 10px;
    box-shadow: 0 4px 20px var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.info {
    border-left: 4px solid var(--accent);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading Spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .logo h1 {
        font-size: 1.8rem;
    }
    
    .tool-section {
        padding: 20px;
    }
    
    .tool-options {
        flex-direction: column;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .theme-toggle {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
