/**
 * QR Code Generator Pro - Enhancements Module
 * Version: 1.2
 *
 * Features included:
 * - Color Picker Presets
 * - QR Preview Modal
 * - Template/Favorites System
 * - Bulk Actions in History
 * - Advanced Logo Options
 *
 * To remove this feature:
 * Simply remove the <link> tag referencing this CSS file from index.php
 */

/* ============================================================== */
/* COLOR PRESETS                                                  */
/* ============================================================== */

.color-presets-section {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.color-presets-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-presets-section h4 i {
    color: var(--primary-color);
}

.color-presets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.color-preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

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

.color-preset-btn.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.color-preset-preview {
    display: flex;
    gap: 4px;
    width: 100%;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.color-preset-preview span {
    flex: 1;
}

/* Recent Colors Remove Button */
.recent-color-btn {
    position: relative;
}

.remove-recent-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.recent-color-btn:hover .remove-recent-btn {
    opacity: 1;
}

.remove-recent-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 768px) {
    .color-presets-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* On mobile, always show remove button since hover doesn't work well */
    .remove-recent-btn {
        opacity: 0.7;
    }

    .remove-recent-btn:active {
        opacity: 1;
    }
}

/* ============================================================== */
/* PREVIEW MODAL                                                  */
/* ============================================================== */

.qr-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.qr-preview-modal.active {
    display: flex;
}

.qr-preview-content {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.qr-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
}

.qr-preview-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.qr-preview-header h3 i {
    color: var(--primary-color);
}

.qr-preview-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.qr-preview-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.qr-preview-body {
    padding: 30px 25px;
}

.qr-preview-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    margin-bottom: 25px;
}

.qr-preview-image-wrapper img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.qr-preview-info {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.qr-preview-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.qr-preview-info-row:last-child {
    border-bottom: none;
}

.qr-preview-info-row span:first-child {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.qr-preview-info-row span:last-child {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.qr-preview-format-selector {
    margin-bottom: 20px;
}

.qr-preview-format-selector label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.qr-preview-format-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

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

.qr-preview-format-btn:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

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

.qr-preview-actions {
    display: flex;
    gap: 10px;
}

.qr-preview-actions .btn {
    flex: 1;
}

/* Responsive */
@media (max-width: 600px) {
    .qr-preview-content {
        border-radius: 12px;
    }

    .qr-preview-header {
        padding: 20px;
    }

    .qr-preview-body {
        padding: 20px;
    }

    .qr-preview-image-wrapper {
        padding: 20px;
    }

    .qr-preview-format-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .qr-preview-actions {
        flex-direction: column;
    }
}

/* ============================================================== */
/* TEMPLATE SYSTEM                                                */
/* ============================================================== */

.template-section {
    margin-bottom: 20px;
}

.template-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.template-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    font-size: 14px;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.template-card {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.template-card.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.template-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.template-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.template-delete {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.template-delete:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

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

.template-color-preview {
    display: flex;
    gap: 4px;
}

.template-color-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.template-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.template-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.template-empty i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.3;
}

.template-empty p {
    font-size: 16px;
}

/* Template Modal */
.template-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.template-modal.active {
    display: flex;
}

.template-modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 100%;
    animation: modalSlideIn 0.3s ease;
}

.template-modal-header {
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
}

.template-modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.template-modal-body {
    padding: 25px;
}

.template-modal-body label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.template-modal-body input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.template-modal-body input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.template-modal-actions {
    display: flex;
    gap: 10px;
}

.template-modal-actions .btn {
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .template-actions {
        flex-direction: column;
    }

    .templates-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================== */
/* BULK ACTIONS (HISTORY ENHANCEMENTS)                           */
/* ============================================================== */

.history-bulk-actions {
    display: none;
    gap: 10px;
    padding: 15px 20px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    align-items: center;
}

.history-bulk-actions.active {
    display: flex;
}

.bulk-actions-info {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
}

.bulk-actions-buttons {
    display: flex;
    gap: 10px;
}

.history-select-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.history-select-all:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.history-select-all input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.history-card-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    z-index: 10;
    accent-color: var(--primary-color);
}

.history-card {
    position: relative;
}

.history-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .history-bulk-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .bulk-actions-buttons {
        flex-direction: column;
    }
}

/* ============================================================== */
/* QR CODE STYLES                                                 */
/* ============================================================== */

.qr-styles-section {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.qr-styles-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.qr-styles-section h4 i {
    color: var(--primary-color);
}

.qr-styles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.qr-style-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    min-height: 70px;
}

.qr-style-btn i {
    font-size: 24px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.qr-style-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.qr-style-btn:hover i {
    color: var(--primary-color);
    transform: scale(1.1);
}

.qr-style-btn.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.qr-style-btn.active i {
    color: var(--primary-color);
}

.qr-styles-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.qr-styles-info i {
    color: var(--primary-color);
    font-size: 14px;
}

/* Responsive - QR Styles */
@media (max-width: 768px) {
    .qr-styles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .qr-style-btn {
        padding: 10px 6px;
        min-height: 65px;
    }

    .qr-style-btn i {
        font-size: 20px;
    }

    .qr-style-btn span {
        font-size: 10px;
    }
}

/* ============================================================== */
/* ADVANCED LOGO OPTIONS                                          */
/* ============================================================== */

.logo-advanced-options {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    animation: slideDown 0.3s ease;
}

.logo-advanced-options.active {
    display: block;
}

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

.logo-advanced-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.logo-advanced-toggle:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.logo-advanced-toggle i {
    transition: transform 0.3s ease;
}

.logo-advanced-toggle.active i {
    transform: rotate(180deg);
}

.logo-option-group {
    margin-bottom: 15px;
}

.logo-option-group:last-child {
    margin-bottom: 0;
}

.logo-option-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.logo-option-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-color);
}

.logo-option-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.logo-option-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.logo-option-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.logo-option-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: none;
    transition: all 0.2s ease;
}

.logo-option-group input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.logo-checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logo-checkbox-group:hover {
    background: rgba(99, 102, 241, 0.05);
}

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

.logo-checkbox-group label {
    flex: 1;
    cursor: pointer;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
}

.logo-effects-preview {
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-primary);
    border-radius: 8px;
    text-align: center;
}

.logo-effects-preview img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.logo-effects-preview p {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .logo-advanced-options {
        padding: 12px;
    }

    .logo-option-group {
        margin-bottom: 12px;
    }
}
