@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Plus+Jakarta+Sans:wght@300;400;600&display=swap');

:root {
    --bg-dark: #050505;
    --card-dark: #0d0d0f;
    --primary: #00f2ff;
    --accent: #7000ff;
    --text-main: #ffffff;
    --text-dim: #94a3b8;
    --error: #ff4d4d;
    --glass-border: rgba(255, 255, 255, 0.08);
    --transition: all 0.4s cubic-bezier(0.2, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-height: 100vh;
    padding: 40px 20px;
    display: flex; /* German: لجعل التذييل يلتصق بالأسفل */
    flex-direction: column; /* German: لجعل التذييل يلتصق بالأسفل */
}

.qr-app-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    flex-grow: 1; /* German: لجعل المحتوى ينمو ويضغط التذييل للأسفل */
}

/* Header Improvements */
.qr-header { text-align: center; margin-bottom: 50px; }
.nav-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.btn-back { color: var(--text-dim); text-decoration: none; display: flex; align-items: center; gap: 8px; font-weight: 600; transition: 0.3s; font-size: 1.2rem; /* Reduced font size */ }
.btn-back:hover { color: var(--primary); transform: translateX(-5px); }
.brand { font-family: 'Outfit'; font-weight: 800; font-size: 2rem; letter-spacing: 1px; }
.brand span { color: var(--primary); }

.qr-header h1 { font-family: 'Outfit'; font-size: clamp(2.5rem, 5vw, 4.5rem); font-weight: 800; margin-bottom: 10px; }
.qr-header h1 span { color: var(--primary); }
.qr-header p { color: var(--text-dim); font-size: clamp(1.1rem, 2vw, 1.4rem); /* Reduced font size */ max-width: 700px; margin: 0 auto; }

/* Grid Layout Fixes */
.qr-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 30px;
    align-items: start;
}

.card-glass {
    background: var(--card-dark);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 25px;
    margin-bottom: 20px;
}

/* Tab Component Fixes */
.config-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: thin;
}
.tab-item {
    background: #16161a;
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 12px 20px;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}
.tab-item.active { background: var(--primary); color: #000; border-color: var(--primary); }

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.4s ease; }

@keyframes fadeIn { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }

/* Form Elements Improvements */
label { display: block; margin-bottom: 8px; color: var(--text-dim); font-size: 1rem; /* Reduced font size */ font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; /* Reduced letter spacing */ }
input, textarea, select {
    width: 100%;
    background: #111114;
    border: 1px solid var(--glass-border);
    padding: 12px 15px; /* Adjusted padding */
    border-radius: 12px;
    color: #fff;
    font-size: 1.1rem; /* Reduced font size */
    outline: none;
    transition: 0.3s;
    margin-bottom: 15px;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 10px rgba(0, 242, 255, 0.15); /* Adjusted shadow */ }
textarea { height: 100px; resize: vertical; /* Allow vertical resize */ }
.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

/* Input Hints */
.input-hint {
    display: block;
    color: var(--error);
    font-size: 0.9rem;
    margin-top: -10px;
    margin-bottom: 15px;
    height: 1.2rem;
    font-weight: 600;
    transition: 0.3s;
}

/* Style Grouping for Pattern/Corners */
.style-group { margin-bottom: 20px; }
.style-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
}

.style-choice {
    background: #1a1a1e;
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 10px 14px; /* Adjusted padding */
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem; /* Adjusted font size */
    font-weight: 600;
    transition: var(--transition);
    flex: 1;
    min-width: 80px;
    text-align: center;
}

.style-choice:hover {
    border-color: var(--primary);
    color: #fff;
}

.style-choice.active {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

/* Accordion Styling Fixes */
.design-section h3 { margin-bottom: 20px; font-family: 'Outfit'; font-size: 1.8rem; /* Adjusted font size */ display: flex; align-items: center; gap: 10px; color: var(--primary); }
.acc-box { border: 1px solid var(--glass-border); border-radius: 15px; margin-bottom: 10px; background: rgba(255,255,255,0.01); overflow: hidden; }
.acc-btn { width: 100%; border: none; background: none; padding: 18px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; color: var(--text-dim); transition: 0.3s; font-size: 1.2rem; /* Adjusted font size */ text-align: left; }
.acc-btn:hover { color: #fff; background: rgba(255,255,255,0.03); }
.acc-panel { padding: 0 20px; max-height: 0; overflow: hidden; transition: all 0.4s ease-out; }
.acc-panel.active { padding: 20px; max-height: 800px; border-top: 1px solid var(--glass-border); }

/* Color Control Styling */
.color-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 20px;
    justify-content: center;
}

.c-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.c-item label {
    margin-bottom: 0;
    font-size: 1.1rem;
    color: var(--text-dim);
}

.c-item input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 55px;
    height: 55px;
    background-color: transparent;
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    transition: var(--transition);
}

.c-item input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.c-item input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.c-item input[type="color"]:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

/* Logo Library */
.logo-categories {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
    justify-content: flex-start;
    overflow-x: auto;
}

.cat-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    color: var(--text-dim);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.cat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.cat-btn.active {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

.logo-presets { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; margin-bottom: 20px; }
.logo-presets img { width: 42px; height: 42px; background: white; padding: 6px; border-radius: 10px; cursor: pointer; transition: 0.3s; border: 2px solid transparent; }
.logo-presets img:hover { border-color: var(--primary); transform: scale(1.1); }

/* Buttons */
.btn-reset {
    width: 100%;
    margin-top: 20px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    border-radius: 15px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
}
.btn-reset:hover {
    background: rgba(255, 77, 77, 0.1);
    color: #ff4d4d;
    border-color: rgba(255, 77, 77, 0.3);
    transform: translateY(-2px);
}

/* Preview Panel Sticky */
.qr-preview-panel {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.preview-card {
    background: var(--card-dark);
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: 35px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
}

/* New wrapper for QR code and copy button */
.qr-code-wrapper {
    position: relative; /* Establish positioning context for copy button */
    width: 100%;
    max-width: 340px;
    margin-bottom: 25px; /* Keep original margin-bottom from #canvas-container */
}

#canvas-container {
    background: white;
    padding: 20px;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    width: 100%;
    height: auto; /* Allow height to adjust to content */
    margin-bottom: 0; /* Remove margin from here, moved to .qr-code-wrapper */
}

/* Make canvas responsive inside its container */
#canvas-container canvas {
    max-width: 100%;
    height: auto;
    display: block; /* Remove extra space below canvas */
}

/* German: Geänderte Download- und Druckgruppen */
.download-controls-group, .print-controls-group {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* Common styles for download/print selects */
.btn-dl-select {
    padding: 15px;
    border-radius: 15px;
    font-weight: 800;
    font-size: 1.1rem;
    background: #1a1a1e;
    color: #fff;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' style='fill: rgba(255, 255, 255, 1);transform: ;msFilter:'%3D%3D'%3E%3Cpath d='M16.293 9.293 12 13.586 7.707 9.293l-1.414 1.414L12 16.414l5.707-5.707z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 24px;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.btn-dl-select:hover {
    border-color: var(--primary);
    box-shadow: 0 12px 25px rgba(0, 242, 255, 0.3);
    transform: translateY(-3px);
    filter: brightness(1.1);
}

/* Common styles for download/print buttons */
.btn-dl-button {
    padding: 15px;
    border-radius: 15px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.btn-dl-button:hover {
    transform: translateY(-3px);
    filter: brightness(1.1);
}

#btn-trigger-download {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    text-shadow: none;
}

#btn-trigger-download:hover {
    box-shadow: 0 12px 25px rgba(0, 242, 255, 0.3);
}

.btn-dl.print { /* Specific style for print button */
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-dl.print:hover {
    box-shadow: 0 12px 25px rgba(112, 0, 255, 0.3);
}

/* Copy button as an overlay */
#btn-copy-clipboard {
    position: absolute;
    top: 15px; /* Adjust as needed */
    right: 15px; /* Adjust as needed */
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6); /* Semi-transparent background */
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem; /* Icon size */
    cursor: pointer;
    transition: var(--transition);
    z-index: 10; /* Ensure it's above the QR code */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

#btn-copy-clipboard:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    transform: scale(1.1);
}

.hint { margin-top: 15px; color: var(--text-dim); font-size: 1.1rem; }

/* German: Footer Styles */
.app-footer {
    margin-top: 50px; /* German: مسافة علوية من المحتوى */
    padding: 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
    border-top: 1px solid var(--glass-border); /* German: خط فاصل علوي */
}

/* Responsive Media Queries */
@media (max-width: 1000px) {
    .qr-container { grid-template-columns: 1fr; }
    .qr-preview-panel { position: static; order: -1; }
    .preview-card { max-width: 400px; /* Adjusted max-width for better mobile fit */ margin: 0 auto 30px; }
    .qr-code-wrapper { max-width: 300px; /* Adjusted max-width */ }
}

@media (max-width: 768px) { /* New breakpoint for tablets */
    .input-grid { grid-template-columns: 1fr; } /* Stack inputs on smaller tablets */
    .history-list-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); } /* Adjust history grid */
    .download-controls-group, .print-controls-group { grid-template-columns: 1fr; } /* Stack download/print buttons */
    body { padding: 20px 15px; } /* German: تقليل الهوامش أكثر على الأجهزة اللوحية والهواتف */
    .app-footer {
        margin-top: 30px;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    body { padding: 15px 10px; } /* German: أقل هوامش على الهواتف الصغيرة */
    .card-glass { padding: 20px; }
    .config-tabs { gap: 5px; }
    .tab-item { padding: 10px 15px; font-size: 1rem; } /* Adjusted font size */
    .qr-header h1 { font-size: 2.5rem; } /* Fixed font size for small screens */
    .qr-header p { font-size: 1rem; } /* Fixed font size for small screens */
    .btn-back { font-size: 1rem; } /* Adjusted font size */
    .brand { font-size: 1.5rem; } /* Adjusted font size */
    .download-controls-group, .print-controls-group { grid-template-columns: 1fr; }
    .app-footer {
        margin-top: 20px;
        padding: 10px;
        font-size: 0.8rem;
    }
}

/* German: Sprachwechsler-Stile */
.lang-switcher {
    display: flex;
    gap: 5px;
    background: #16161a;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 5px;
}

.lang-switcher button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
}

.lang-switcher button:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.lang-switcher button.active {
    background: var(--primary);
    color: #000;
}

/* German: Stile für die Historie */
.history-section h3 { margin-bottom: 20px; font-family: 'Outfit'; font-size: 2rem; display: flex; align-items: center; gap: 10px; color: var(--primary); }
.history-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* More flexible columns */
    gap: 15px;
    margin-top: 20px;
}
.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    color: var(--text-dim);
    font-size: 1.1rem;
    transition: var(--transition);
}
.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-3px);
}
.history-timestamp {
    font-weight: 400;
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 10px;
}
.btn-apply-history {
    background: var(--primary);
    color: #000;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
    align-self: flex-end;
    margin-top: 10px;
}
.btn-apply-history:hover {
    filter: brightness(1.1);
}

/* German: Stile für den Clear History Button */
#btn-clear-history {
    margin-top: 20px;
    background: rgba(255, 77, 77, 0.1);
    color: #ff4d4d;
    border-color: rgba(255, 77, 77, 0.3);
}
#btn-clear-history:hover {
    background: rgba(255, 77, 77, 0.2);
    transform: translateY(-2px);
}

/* German: Stile für QR-Vorschau in der Historie */
.qr-preview-thumbnail {
    width: 100px;
    height: 100px;
    background: white;
    padding: 5px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.qr-preview-thumbnail canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.history-item .history-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}
.history-item .history-type {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 5px;
}


/* German: Stile für Logo-Steuerelemente */
.logo-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 15px;
    border: 1px solid var(--glass-border);
}

.logo-controls .control-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logo-controls .control-item label {
    font-size: 0.9rem; /* Adjusted font size */
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-main);
}

.logo-controls .control-item input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: #333;
    outline: none;
    border-radius: 5px;
    transition: opacity .2s;
    margin-bottom: 0;
}

.logo-controls .control-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 5px rgba(0, 242, 255, 0.5);
}

.logo-controls .control-item input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 242, 255, 0.5);
}

.logo-controls .control-item input[type="range"]::-webkit-slider-runnable-track {
    background: #555;
    border-radius: 5px;
}

.logo-controls .control-item input[type="range"]::-moz-range-track {
    background: #555;
    border-radius: 5px;
}

.logo-controls .control-item span {
    font-size: 0.9rem;
    color: var(--text-dim);
    text-align: right;
    margin-top: 5px;
}

/* German: Stile für Druckfunktionen */
/* Removed specific .print-controls select and applied .btn-dl-select */

/* German: Druckstile */
@media print {
    body * {
        visibility: hidden;
    }
    .print-area, .print-area * {
        visibility: visible;
    }
    .print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0;
        padding: 0;
        background: white;
    }
    .print-area img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    /* German: Spezifische Größen für den Druck */
    .print-size-business_card {
        width: 85mm;
        height: 55mm;
    }
    .print-size-sticker {
        width: 100mm;
        height: 100mm;
    }
    .print-size-poster {
        width: 297mm;
        height: 420mm;
    }
}

/* German: Stile für die Passwortstärkeanzeige */
.password-strength {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: -10px;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--text-dim);
}

.password-strength span {
    font-weight: 600;
}

.password-strength #password-strength-indicator {
    padding: 5px 10px;
    border-radius: 8px;
    font-weight: 700;
    color: #000;
}

.strength-none {
    background-color: #555;
    color: #fff !important;
}

.strength-weak {
    background-color: #ff4d4d;
}

.strength-medium {
    background-color: #ffcc00;
}

.strength-strong {
    background-color: #4CAF50;
}

/* Custom Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-dark);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 30px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-message {
    font-size: 1.6rem;
    color: var(--text-main);
    margin-bottom: 25px;
    line-height: 1.4;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-buttons button {
    flex: 1;
    max-width: 150px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

#custom-confirm-yes {
    background: var(--error);
    color: #fff;
    border: 1px solid var(--error);
}

#custom-confirm-yes:hover {
    background: rgba(255, 77, 77, 0.8);
    transform: translateY(-2px);
}

#custom-confirm-no {
    background: var(--card-dark);
    color: var(--text-dim);
    border: 1px solid var(--glass-border);
}

#custom-confirm-no:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateY(-2px);
}