/* ===================================
   MODERN TEMPLATE UI DESIGN
   By Sophia - Matrix Theme Integration
   =================================== */

:root {
    --matrix-green: #b841ff;
    --matrix-dark-green: #7a11a8;
    --matrix-bg: #0e0a14;
    --matrix-card: rgba(20, 0, 40, 0.95);
    --matrix-border: rgba(184, 65, 255, 0.3);
    --matrix-glow: 0 0 20px rgba(184, 65, 255, 0.5);
    --matrix-text: #e0d0ff;
    --matrix-highlight: #ff41ff;
}

/* Template Creator Modal - Futuristic Design */
#templateCreatorModal {
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(20px) saturate(180%);
    }
}

#templateCreatorModal .modal-content {
    background: linear-gradient(135deg, rgba(18, 18, 18, 0.98) 0%, rgba(30, 30, 30, 0.98) 100%);
    border: 2px solid transparent;
    background-clip: padding-box;
    position: relative;
    border-radius: 24px;
    width: 100%;
    max-width: 900px;
    max-height: 95vh;
    overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 
        0 24px 48px rgba(138, 43, 226, 0.2),
        0 0 100px rgba(255, 0, 255, 0.1);
}

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

/* Animated gradient border */
#templateCreatorModal .modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 24px;
    padding: 2px;
    background: linear-gradient(145deg, var(--primary) 0%, var(--accent) 50%, var(--primary) 100%);
    background-size: 200% 200%;
    animation: borderGradient 3s ease infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: exclude;
    mask-composite: exclude;
    z-index: -1;
}

@keyframes borderGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Modal Header - Futuristic Style */
#templateCreatorModal .modal-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, rgba(138, 43, 226, 0.3) 100%);
    color: var(--text);
    border-bottom: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 22px 22px 0 0;
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}

#templateCreatorModal .modal-header h3 {
    color: var(--text);
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 1px;
    text-shadow: 0 0 20px rgba(138, 43, 226, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#templateCreatorModal .modal-header h3 i {
    font-size: 1.3rem;
    color: var(--accent);
    filter: drop-shadow(0 0 10px var(--accent));
    animation: iconPulse 2s ease-in-out infinite;
}

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

/* Close Button - Modern Style */
#templateCreatorModal .close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

#templateCreatorModal .close-btn:hover {
    background: rgba(255, 0, 0, 0.2);
    border-color: rgba(255, 0, 0, 0.4);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.3);
}

/* Template Creator Container */
.template-creator-container {
    max-width: 850px;
    margin: 0 auto;
    padding: 2rem;
    color: var(--text);
    overflow-y: auto;
    max-height: calc(95vh - 100px);
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.template-creator-container::-webkit-scrollbar {
    width: 8px;
}

.template-creator-container::-webkit-scrollbar-track {
    background: transparent;
}

.template-creator-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

/* Form Sections - Glassmorphism Effect */
.template-creator-container .form-section {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.1) 0%, rgba(255, 0, 255, 0.05) 100%);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(138, 43, 226, 0.2);
    box-shadow:
        0 8px 32px rgba(138, 43, 226, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    text-align: center;
}

/* But keep form groups left-aligned */
.template-creator-container .form-section .form-group {
    text-align: left;
}

.template-creator-container .form-section::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(145deg, var(--primary), var(--accent), var(--primary));
    border-radius: 16px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.template-creator-container .form-section:hover::before {
    opacity: 0.1;
}

/* Section Headers */
.template-creator-container .form-section h4 {
    color: var(--text);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    font-weight: 600;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 10px rgba(138, 43, 226, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.template-creator-container .form-section h4 i {
    color: var(--accent);
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px var(--accent));
}

/* Form Groups - Modern Inputs */
.template-creator-container .form-group {
    margin-bottom: 1.75rem;
}

.template-creator-container .form-group label {
    color: var(--text);
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.template-creator-container .form-group label i {
    color: var(--primary-light);
    font-size: 0.9rem;
}

.template-creator-container .form-group input,
.template-creator-container .form-group textarea {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(138, 43, 226, 0.2);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    color: var(--text);
    width: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
}

.template-creator-container .form-group input::placeholder,
.template-creator-container .form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.template-creator-container .form-group input:focus,
.template-creator-container .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 
        0 0 0 4px rgba(138, 43, 226, 0.1),
        0 0 20px rgba(138, 43, 226, 0.2),
        inset 0 0 10px rgba(138, 43, 226, 0.05);
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-2px);
}

.template-creator-container .form-group textarea {
    resize: vertical;
    min-height: 120px;
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
}

.template-creator-container .form-group small {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: block;
    opacity: 0.8;
    font-style: italic;
}

/* Commands Container - Futuristic Style */
.commands-container {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6) 0%, rgba(138, 43, 226, 0.05) 100%);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid rgba(138, 43, 226, 0.2);
    box-shadow: 
        inset 0 2px 10px rgba(0, 0, 0, 0.3),
        0 4px 20px rgba(138, 43, 226, 0.1);
    position: relative;
    text-align: center;
}

/* Floating Animation Background */
.commands-container::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 0, 255, 0.1) 0%, transparent 70%);
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -30px) rotate(120deg); }
    66% { transform: translate(-20px, 20px) rotate(240deg); }
}

.command-inputs {
    margin-bottom: 2rem;
    text-align: left;
}

/* Command Items - Modern Cards */
.command-item {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1rem;
    animation: slideInLeft 0.3s ease;
    position: relative;
    background: rgba(138, 43, 226, 0.05);
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(138, 43, 226, 0.2);
    transition: all 0.3s ease;
}

.command-item:hover {
    background: rgba(138, 43, 226, 0.1);
    border-color: rgba(138, 43, 226, 0.3);
    transform: translateX(5px);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.command-item input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(138, 43, 226, 0.2);
    border-radius: 10px;
    padding: 0.875rem 1rem;
    color: var(--text);
    transition: all 0.3s ease;
    font-family: 'Fira Code', 'Courier New', monospace;
}

.command-item input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.3);
    background: rgba(0, 0, 0, 0.6);
}

.command-item input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

/* Remove Button - Modern Style */
.remove-command {
    flex-shrink: 0;
    min-width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.2) 0%, rgba(220, 20, 60, 0.2) 100%);
    border: 2px solid rgba(255, 0, 0, 0.3);
    color: #ff6b6b;
    transition: all 0.3s ease;
    cursor: pointer;
}

.remove-command:hover {
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.4) 0%, rgba(220, 20, 60, 0.4) 100%);
    border-color: rgba(255, 0, 0, 0.5);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.3);
}

/* Add Command Button - Neon Effect */
#addCommandBtn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    color: var(--text);
    font-weight: 600;
    padding: 0.875rem 2rem;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 15px rgba(138, 43, 226, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    display: block;
    margin: 0 auto;
    cursor: pointer;
}

#addCommandBtn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#addCommandBtn:hover::before {
    width: 300px;
    height: 300px;
}

#addCommandBtn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(138, 43, 226, 0.4),
        0 0 30px rgba(255, 0, 255, 0.3);
}

/* Prevent yellow background on autofocus */
#addCommandBtn:focus,
#addCommandBtn:active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%) !important;
    outline: none !important;
}

/* Preview Container - Terminal Style */
.template-preview {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7) 0%, rgba(138, 43, 226, 0.1) 100%);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(138, 43, 226, 0.3);
    min-height: 150px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Animated Scanline Effect */
.template-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: scanline 3s linear infinite;
}

@keyframes scanline {
    0% { transform: translateY(-10px); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(160px); opacity: 0; }
}

.preview-content {
    color: var(--text);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
}

.preview-content pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--primary-light);
    text-shadow: 0 0 10px rgba(138, 43, 226, 0.3);
    animation: codeGlow 2s ease-in-out infinite alternate;
}

@keyframes codeGlow {
    from { filter: brightness(1); }
    to { filter: brightness(1.2); }
}

.preview-container:empty::before {
    content: "Commands will be merged here...";
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

/* Modal Actions - Button Group */
.template-creator-container .modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(138, 43, 226, 0.2);
}

/* Buttons - Modern Style */
.template-creator-container .btn {
    padding: 0.875rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.template-creator-container .btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    color: var(--text);
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

.template-creator-container .btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.template-creator-container .btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.template-creator-container .btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 6px 20px rgba(138, 43, 226, 0.4),
        0 0 30px rgba(255, 0, 255, 0.3);
}

.template-creator-container .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(138, 43, 226, 0.3);
    color: var(--text);
    backdrop-filter: blur(10px);
}

.template-creator-container .btn-secondary:hover {
    background: rgba(138, 43, 226, 0.2);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

/* Template Cards - Matrix Style from Account Page */
.template-card {
    background: rgba(20, 0, 40, 0.95);
    border: 1px solid rgba(184, 65, 255, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* Matrix Card Glow Effect */
.template-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #b841ff, transparent, #b841ff);
    border-radius: 12px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

/* Matrix Card Hover Effects */
.template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 30px rgba(184, 65, 255, 0.5);
}

.template-card:hover::before {
    opacity: 0.3;
}

.template-card > * {
    position: relative;
    z-index: 2;
}

/* Card Content Styling - Matrix Theme */
.template-card h3 {
    color: #e0d0ff;
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-shadow: 0 0 10px rgba(184, 65, 255, 0.5);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.template-card h3 i {
    color: #b841ff;
    filter: drop-shadow(0 0 5px #b841ff);
}

.template-card .template-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: rgba(184, 65, 255, 0.7);
}

.template-card .template-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: rgba(184, 65, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(184, 65, 255, 0.2);
    transition: all 0.3s ease;
}

.template-card .template-meta-item:hover {
    background: rgba(184, 65, 255, 0.15);
    border-color: rgba(184, 65, 255, 0.3);
}

.template-card .template-meta-item i {
    color: #b841ff;
    font-size: 0.75rem;
}

/* Card Actions - Matrix Style Buttons */
.template-card .template-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.template-card .btn {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.85rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-align: center;
    font-family: 'Orbitron', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    background: rgba(184, 65, 255, 0.1);
    border: 1px solid rgba(184, 65, 255, 0.3);
    color: #b841ff;
    cursor: pointer;
}

.template-card .btn:hover {
    transform: translateY(-2px);
    background: rgba(184, 65, 255, 0.2);
    border-color: #b841ff;
    box-shadow: 0 0 15px rgba(184, 65, 255, 0.4);
    text-shadow: 0 0 5px rgba(184, 65, 255, 0.5);
}

.template-card .btn i {
    margin-right: 0.4rem;
}

/* Specific button styles for Edit and Delete */
.template-card .btn.primary {
    background: rgba(184, 65, 255, 0.15);
    color: #b841ff;
    border-color: rgba(184, 65, 255, 0.4);
}

.template-card .btn.primary:hover {
    background: rgba(184, 65, 255, 0.25);
    border-color: #b841ff;
    color: #ff41ff;
}

.template-card .btn.secondary {
    background: rgba(255, 68, 68, 0.1);
    color: #ff6b6b;
    border-color: rgba(255, 68, 68, 0.3);
}

.template-card .btn.secondary:hover {
    background: rgba(255, 68, 68, 0.2);
    border-color: #ff4444;
    color: #ff4444;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.3);
}

/* Template Code Display - Matrix Style */
.template-code-display {
    background: rgba(10, 0, 20, 0.8);
    border: 1px solid rgba(184, 65, 255, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.template-code-display::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -100%;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #b841ff, transparent);
    animation: codeSlide 3s linear infinite;
}

@keyframes codeSlide {
    to { left: 100%; }
}

.template-code-display code {
    background: rgba(184, 65, 255, 0.1);
    color: #e0d0ff;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid rgba(184, 65, 255, 0.2);
    text-shadow: 0 0 8px rgba(184, 65, 255, 0.4);
    letter-spacing: 0.5px;
}

/* Copy Button - Matrix Style */
.copy-btn {
    background: rgba(40, 167, 69, 0.1);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Orbitron', monospace;
}

.copy-btn:hover {
    background: rgba(40, 167, 69, 0.2);
    border-color: rgba(74, 222, 128, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.3);
    text-shadow: 0 0 5px rgba(74, 222, 128, 0.5);
}

.copy-btn.success {
    background: rgba(40, 167, 69, 0.3);
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive Design - Mobile First Approach */
@media (max-width: 768px) {
    /* Modal Optimizations */
    #templateCreatorModal {
        padding: 0;
    }

    #templateCreatorModal .modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        animation: mobileSlideUp 0.3s ease;
    }

    @keyframes mobileSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    #templateCreatorModal .modal-header {
        padding: 0.75rem;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: rgba(18, 18, 18, 0.98);
        height: 60px; /* Fixed height for header */
        display: flex;
        align-items: center;
    }

    #templateCreatorModal .modal-header h3 {
        font-size: 1rem;
        letter-spacing: 0;
    }

    #templateCreatorModal .modal-header h3 i {
        font-size: 0.9rem;
    }

    #templateCreatorModal .close-btn {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    /* Container Adjustments */
    .template-creator-container {
        padding: 0.5rem;
        padding-top: 80px; /* Account for fixed header */
        max-height: calc(100vh - 60px);
        margin-top: 0; /* Remove any default margin */
    }

    .template-creator-container .form-section {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        border-radius: 8px;
    }

    .template-creator-container .form-section h4 {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
        gap: 0.5rem;
    }

    .template-creator-container .form-section h4 i {
        font-size: 0.85rem;
    }

    /* Form Elements - Compact */
    .template-creator-container .form-group {
        margin-bottom: 1rem;
    }

    .template-creator-container .form-group label {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }

    .template-creator-container .form-group input,
    .template-creator-container .form-group textarea {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
        border-radius: 8px;
    }

    .template-creator-container .form-group textarea {
        min-height: 80px;
    }

    .template-creator-container .form-group small {
        font-size: 0.75rem;
        margin-top: 0.25rem;
    }

    /* Commands Container - Mobile Optimized */
    .commands-container {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .command-inputs {
        margin-bottom: 0.75rem;
    }

    .command-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
        padding: 0.4rem;
        border-radius: 6px;
    }

    .command-item input {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.85rem;
        border-radius: 6px;
    }

    .remove-command {
        min-width: 30px;
        height: 30px;
        border-radius: 6px;
        font-size: 0.8rem;
    }

    /* Add Command Button - Compact */
    #addCommandBtn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        border-radius: 8px;
        width: auto;
        max-width: 200px;
        margin: 0 auto;
        display: block;
    }

    /* Prevent yellow focus state on mobile */
    #addCommandBtn:focus,
    #addCommandBtn:active,
    #addCommandBtn:focus-visible {
        background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%) !important;
        outline: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    /* Preview Container - Compact */
    .template-preview {
        padding: 0.75rem;
        border-radius: 8px;
        min-height: 80px;
    }

    .preview-content {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    /* Modal Actions - Mobile Layout */
    .template-creator-container .modal-actions {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        position: sticky;
        bottom: 0;
        background: rgba(18, 18, 18, 0.98);
        margin: 0 -0.5rem;
        padding: 0.75rem;
        border-top: 1px solid rgba(138, 43, 226, 0.3);
    }

    .template-creator-container .btn {
        flex: 1;
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
        border-radius: 8px;
    }

    /* Template Cards - Ultra Compact Matrix Style */
    .template-card {
        padding: 1rem;
        border-radius: 8px;
        margin-bottom: 0.75rem;
        background: rgba(20, 0, 40, 0.95);
        border: 1px solid rgba(184, 65, 255, 0.3);
    }

    .template-card h3 {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
        font-family: 'Orbitron', monospace;
        color: #e0d0ff;
        text-shadow: 0 0 8px rgba(184, 65, 255, 0.4);
    }

    .template-card h3 i {
        font-size: 0.85rem;
    }

    .template-card .template-meta {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
        font-size: 0.75rem;
    }

    .template-card .template-meta-item {
        padding: 0.25rem 0.5rem;
        border-radius: 12px;
        font-size: 0.7rem;
    }

    .template-card .template-meta-item i {
        font-size: 0.7rem;
    }

    /* Template Code Display - Mobile Optimized */
    .template-code-display {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem;
        border-radius: 8px;
        margin-bottom: 0.75rem;
    }

    .template-code-display code {
        flex: 1;
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        border-radius: 6px;
        text-align: left;
        overflow-x: auto;
        white-space: nowrap;
    }

    .copy-btn {
        flex-shrink: 0;
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        border-radius: 6px;
    }

    .copy-btn span {
        display: none;
    }

    /* Template Actions - Horizontal Layout */
    .template-card .template-actions {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
    }

    .template-card .btn {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.8rem;
        border-radius: 8px;
    }

    /* Reduce animations on mobile */
    .template-card::before,
    .template-card::after,
    .commands-container::after,
    .template-preview::before {
        display: none;
    }

    /* Simplify hover states */
    .template-card:hover {
        transform: none;
        box-shadow: 0 0 20px rgba(184, 65, 255, 0.3);
    }

    /* Form Row - Stack on Mobile */
    .template-creator-container .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Adjust content grid */
    .content-grid {
        padding: 0.5rem;
        gap: 0.75rem;
    }

    /* Empty state - Compact */
    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state i {
        font-size: 2rem;
    }

    .empty-state h3 {
        font-size: 1.1rem;
    }

    .empty-state p {
        font-size: 0.85rem;
    }

    .empty-state .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    /* Even more compact for very small screens */
    #templateCreatorModal .modal-header {
        padding: 0.5rem;
    }

    #templateCreatorModal .modal-header h3 {
        font-size: 0.9rem;
    }

    .template-creator-container {
        padding: 0.25rem;
    }

    .template-creator-container .form-section {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .template-card {
        padding: 0.75rem;
    }

    .template-card h3 {
        font-size: 0.85rem;
    }

    .template-code-display code {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .template-card .btn {
        font-size: 0.75rem;
        padding: 0.4rem;
    }
}

/* Landscape Mobile Adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    #templateCreatorModal .modal-content {
        max-height: 100vh;
    }

    .template-creator-container {
        padding-top: 50px;
        max-height: calc(100vh - 50px);
    }

    #templateCreatorModal .modal-header {
        padding: 0.5rem 0.75rem;
    }

    .template-creator-container .form-section {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }
}

/* Animation Utilities */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Hover States for Interactive Elements */
.interactive-element {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.interactive-element:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* Loading States */
.loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Success/Error States */
.success-state {
    border-color: #28a745 !important;
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.3) !important;
}

.error-state {
    border-color: #dc3545 !important;
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.3) !important;
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Focus Styles for Keyboard Navigation */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .template-card {
        page-break-inside: avoid;
        border: 1px solid #ccc;
        box-shadow: none;
    }
    
    .btn, .modal-actions, .template-actions {
        display: none;
    }
}