/* static/style.css */
:root {
    --bg-dark: #12121E; /* Very dark background, closer to black-blue */
    --container-bg: #1F1F30; /* Darker for containers and cards */
    --text-light: #E0E0E0; /* Light text */
    --text-dark-secondary: #9090A0; /* Secondary dark text */
    --accent-red: #FF4A6F; /* Bright red, slightly more saturated */
    --accent-green: #38C172; /* Green */
    --accent-blue-green: #29B3B3; /* Turquoise, slightly more saturated */
    --warning-yellow: #FFC107; /* Yellow for warnings */
    --input-bg: #181827; /* Background for input fields, darker */
    --border-color: #303045; /* Border color, darker and softer */
    --shadow-color-subtle: rgba(0, 0, 0, 0.2); /* Light shadow */
    --shadow-color-strong: rgba(0, 0, 0, 0.4); /* Strong shadow for interactive elements */
    --border-radius-main: 12px; /* Softer rounded corners */
    --border-radius-button: 8px; /* For buttons */
    --transition-speed: 0.25s ease-out; /* Uniform transition speed */

    /* Header specific colors */
    --gradient-header-start: #1F1F30;
    --gradient-header-end: #12121E;
    --header-border-bottom: #303045;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* General styles for all buttons */
.button,
.copy-button,
.modal-content button.primary, /* Targeting the copy button in modals */
.no-templates-message .button,
.form-container .button.primary,
.telegram-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 25px;
    border: none;
    border-radius: var(--border-radius-button);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition-speed), transform 0.1s ease-out, box-shadow var(--transition-speed);
    box-shadow: 0 2px 8px var(--shadow-color-subtle);
    color: white; /* Default text color for buttons */
}

.button:hover,
.copy-button:hover,
.modal-content button.primary:hover,
.no-templates-message .button:hover,
.form-container .button.primary:hover,
.telegram-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--shadow-color-strong);
}

/* Specific button styling */
.button {
    background-color: var(--accent-blue-green);
}
.button:hover {
    background-color: #209999;
}

.button.logout {
    background-color: var(--accent-red);
}
.button.logout:hover {
    background-color: #CC3B5B;
}

.copy-button,
.modal-content button.primary { /* Apply to both copy buttons and primary buttons in modals */
    background-color: var(--accent-red);
}
.copy-button:hover,
.modal-content button.primary:hover {
    background-color: #CC3B5B;
}

.form-container .button.primary,
.no-templates-message .button.primary {
    padding: 15px 30px;
    font-size: 1.1em;
}

/* --- Header Styles --- */
/* --- Header Styles --- */
header {
    background: linear-gradient(to right, var(--gradient-header-start), var(--gradient-header-end));
    color: var(--text-light);
    padding: 18px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    position: sticky;
    top: 0;
    z-index: 500;
    border-bottom: 1px solid var(--header-border-bottom);
}

header h1 {
    margin: 0;
    font-size: 2.5em;
    font-weight: 800;
    color: var(--accent-red);
    letter-spacing: 1.5px;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

/* New styles for the header h1 link */
header h1 a {
    text-decoration: none; /* Removes underline */
    color: inherit; /* Inherits the color from the parent h1 */
    /* If you want to explicitly set the color, use: color: var(--accent-red); */
    cursor: pointer; /* Ensures it looks clickable, even without underline */
    transition: opacity 0.3s ease-out; /* Smooth transition for hover effect */
}

header h1 a:hover {
    opacity: 0.8; /* Slightly dim the text on hover to indicate clickability */
}

.welcome-message {
    margin: 5px 0 0 0;
    font-size: 1.15em;
    opacity: 0.9;
    color: var(--text-light);
    font-weight: 500;
    transition: opacity 0.3s ease-out;
}
.welcome-message:hover {
    opacity: 1;
}

.header-right {
    display: flex;
    gap: 25px;
}

header .button {
    padding: 10px 20px;
    font-size: 0.95em;
    font-weight: 600;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
header .button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

main {
    flex-grow: 1;
    max-width: 1200px;
    margin: 35px auto;
    padding: 0 25px;
    box-sizing: border-box;
}

.search-container {
    margin-top: 35px;
    margin-bottom: 35px;
    text-align: center;
    transition: margin-top var(--transition-speed);
}

#searchInput {
    width: 100%;
    max-width: 650px;
    padding: 15px 28px;
    border: 1px solid var(--border-color);
    border-radius: 35px;
    font-size: 1.15em;
    box-shadow: 0 4px 12px var(--shadow-color-subtle);
    transition: all var(--transition-speed);
    background-color: var(--input-bg);
    color: var(--text-light);
    outline: none;
    box-sizing: border-box;
}

#searchInput::placeholder {
    color: var(--text-dark-secondary);
    opacity: 0.7;
}

#searchInput:focus {
    border-color: var(--accent-blue-green);
    box-shadow: 0 0 15px rgba(41, 179, 179, 0.4);
}

.template-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 28px;
    align-items: stretch; /* All items in a row will have the same height */
    width: 100%;
    box-sizing: border-box;
}

.template-card {
    background-color: var(--container-bg);
    border-radius: var(--border-radius-main);
    box-shadow: 0 5px 20px var(--shadow-color-subtle);
    padding: 28px;
    position: relative;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    display: flex;
    flex-direction: column;
    min-height: 250px; /* Ensures consistent card height, adjusted for more content */
    box-sizing: border-box;
    cursor: pointer; /* Indicate it's clickable */
}

.template-card:hover {
    /* No transform or excessive shadow change to avoid "jumping" */
    box-shadow: 0 8px 25px var(--shadow-color-strong); /* Just a slightly stronger shadow */
    transform: none; /* Ensure no lift */
}


.template-header-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
    box-sizing: border-box;
}

.template-header-top-row .template-type {
    background-color: var(--accent-blue-green);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.template-header-top-row .template-title {
    margin: 0;
    font-size: 1.4em;
    color: var(--text-light);
    flex-grow: 1;
    font-weight: 700;
    line-height: 1.3;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines for title */
    -webkit-box-orient: vertical;
}

.template-issue-row {
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.template-issue-row .issue-tag {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-dark-secondary);
    padding: 6px 12px;
    border-radius: var(--border-radius-button);
    font-size: 0.9em;
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all var(--transition-speed);
    cursor: default;
}

.template-issue-row .issue-tag i {
    margin-right: 5px;
    color: var(--text-dark-secondary);
}

.template-issue-row .issue-tag:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-blue-green);
    color: var(--text-light);
}

/* Standard template content, fixed height with ellipsis */
.template-content {
    flex-grow: 1;
    margin-bottom: 20px;
    color: var(--text-dark-secondary);
    line-height: 1.7;
    max-height: 100px; /* Adjusted max-height to ensure consistent card heights */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Add ellipsis */
    word-wrap: break-word;
    font-size: 0.98em;
    display: -webkit-box;
    -webkit-line-clamp: 4; /* Limit to 4 lines */
    -webkit-box-orient: vertical;
}

.template-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto; /* Pushes to the bottom of the card */
    margin-bottom: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.template-meta .smart-tag {
    background-color: var(--input-bg);
    border: 1px solid var(--warning-yellow);
    color: var(--warning-yellow);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: bold;
    display: inline-flex; /* Use inline-flex for better alignment with icon */
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(255,193,7,0.15);
    transition: all var(--transition-speed);
}
.template-meta .smart-tag i {
    font-size: 0.9em;
}
.template-meta .smart-tag:hover {
    background-color: rgba(255, 193, 7, 0.1);
    box-shadow: 0 4px 10px rgba(255,193,7,0.3);
}

.template-meta .keywords-tag {
    background-color: var(--input-bg);
    color: var(--text-dark-secondary);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all var(--transition-speed);
    display: inline-flex; /* Use inline-flex for better alignment with icon */
    align-items: center;
    gap: 5px;
}
.template-meta .keywords-tag i {
    margin-right: 0; /* Adjusted, already covered by gap */
    color: var(--text-dark-secondary);
}
.template-meta .keywords-tag:hover {
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    color: var(--text-light);
}

.template-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    opacity: 0; /* Hidden by default */
    pointer-events: none; /* No interaction when hidden */
    transition: opacity var(--transition-speed);
    z-index: 10;
}
.template-card:hover .template-actions {
    opacity: 1; /* Show on hover */
    pointer-events: all; /* Enable interaction on hover */
}
.template-actions .action-button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform 0.1s ease-out, border-color var(--transition-speed);
    box-shadow: 0 2px 8px var(--shadow-color-subtle);
}
.template-actions .action-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
}
.template-actions .action-button i {
    color: var(--text-light);
    font-size: 17px;
}
.template-actions .action-button.edit:hover i {
    color: var(--accent-blue-green);
}
.template-actions .action-button.delete:hover i {
    color: var(--accent-red);
}

.no-templates-message {
    text-align: center;
    padding: 60px 30px;
    font-size: 1.3em;
    color: var(--text-light);
    background-color: var(--container-bg);
    border-radius: var(--border-radius-main);
    margin-top: 40px;
    box-shadow: 0 5px 20px var(--shadow-color-subtle);
    line-height: 1.8;
}
.no-templates-message p {
    margin-bottom: 30px;
    font-weight: 500;
}

.template-count {
    text-align: center;
    margin-top: 25px;
    margin-bottom: 25px;
    font-size: 1.25em;
    color: var(--text-light);
    font-weight: bold;
    background-color: var(--container-bg);
    padding: 18px;
    border-radius: var(--border-radius-main);
    box-shadow: 0 2px 8px var(--shadow-color-subtle);
}

.no-searchResults-message { /* Changed from #noSearchResultsMessage to class */
    text-align: center;
    padding: 30px;
    font-size: 1.1em;
    color: var(--text-dark-secondary);
    background-color: var(--container-bg);
    border-radius: var(--border-radius-main);
    margin-top: 25px;
    box-shadow: var(--shadow-color-subtle);
    display: none;
}
.no-searchResults-message i {
    margin-right: 10px;
    color: var(--warning-yellow);
    font-size: 1.3em;
}

/* Modal General Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fadeIn 0.3s forwards;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--container-bg);
    padding: 35px;
    border-radius: var(--border-radius-main);
    width: 90%;
    max-width: 600px; /* Default max-width for smart modal */
    box-shadow: 0 15px 40px var(--shadow-color-strong);
    position: relative;
    animation: slideIn 0.3s ease-out;
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 30px;
    color: var(--accent-red);
    font-size: 2em;
    font-weight: 700;
}

.modal-content .input-group {
    margin-bottom: 20px;
}

.modal-content .input-group label {
    font-weight: 600;
    margin-bottom: 10px;
    display: block;
    color: var(--text-light);
    font-size: 1.05em;
}

.modal-content .input-group input,
.modal-content textarea { /* Combined selector */
    width: calc(100% - 24px);
    padding: 13px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
    background-color: var(--input-bg);
    color: var(--text-light);
    font-family: 'Segoe UI', sans-serif;
    outline: none;
}

.modal-content .input-group input:focus,
.modal-content textarea:focus {
    border-color: var(--accent-blue-green);
    box-shadow: 0 0 8px rgba(41, 179, 179, 0.4);
}

.modal-content textarea {
    min-height: 120px;
    resize: vertical;
}

.close-button {
    color: var(--text-dark-secondary);
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 36px;
    font-weight: normal;
    cursor: pointer;
    transition: color var(--transition-speed), transform 0.1s ease-out;
}

.close-button:hover,
.close-button:focus {
    color: var(--text-light);
    transform: rotate(90deg);
    text-decoration: none;
}

/* Flashes (Notifications) Styling */
.flashes {
    list-style: none;
    padding: 0;
    margin: 0 auto 30px auto;
    max-width: 800px;
    width: 100%;
    position: fixed; /* Position fixed */
    top: 20px; /* From top */
    left: 50%;
    transform: translateX(-50%); /* Center horizontally */
    z-index: 1001; /* Above modals */
    pointer-events: none; /* Allow clicks through to content below */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center flash messages */
    gap: 15px; /* Space between multiple messages */
}

.flashes li {
    padding: 16px 30px;
    border-radius: var(--border-radius-button);
    font-size: 1.05em;
    font-weight: 600;
    text-align: center;
    opacity: 0; /* Start hidden */
    transform: translateY(-20px); /* Start slightly above */
    transition: opacity 0.4s ease-out, transform 0.4s ease-out, box-shadow 0.2s ease-out;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); /* Stronger shadow for visibility */
    pointer-events: auto; /* Enable interaction (e.g., if needed to click away) */
    width: fit-content; /* Adjust width to content */
    min-width: 250px; /* Minimum width */
    max-width: 90%;
}

.flashes li.show {
    opacity: 1;
    transform: translateY(0);
}

.flashes li.hide {
    opacity: 0;
    transform: translateY(-30px); /* Disappear upwards */
    /* To ensure elements are removed after animation */
    transition: opacity 0.5s ease-in, transform 0.5s ease-in;
}

.flashes li.error {
    background-color: var(--accent-red);
    color: white;
    border: 1px solid #dc3545;
}

.flashes li.success {
    background-color: var(--accent-green);
    color: white;
    border: 1px solid #218838;
}

.flashes li.info {
    background-color: var(--accent-blue-green);
    color: white;
    border: 1px solid #117a8b;
}

.flashes li.warning {
    background-color: var(--warning-yellow);
    color: var(--bg-dark);
    border: 1px solid #e0a800;
}

/* --- Full Template View Modal Styles (for clicking on card) --- */
#fullTemplateViewModal .modal-content {
    max-width: 800px; /* Larger max-width for full view */
    padding: 35px;
    display: flex; /* Use flexbox for internal layout */
    flex-direction: column; /* Stack children vertically */
}

#fullTemplateViewModal .modal-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

#fullTemplateViewModal .modal-header-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px; /* Space between top row and bottom row */
    flex-wrap: wrap; /* Allow wrapping if needed */
}

#fullTemplateViewModal .modal-header-top-row .template-type {
    background-color: var(--accent-blue-green);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}
#fullTemplateViewModal .modal-header-top-row .template-type i {
    font-size: 0.9em;
}


#fullTemplateViewModal .template-title-full { /* Specific title for full modal */
    margin: 0;
    font-size: 2.2em;
    color: var(--accent-red);
    font-weight: 700;
    flex-grow: 1;
    line-height: 1.3;
}

#fullTemplateViewModal .modal-header-bottom-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

#fullTemplateViewModal .modal-header-bottom-row .issue-tag {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-dark-secondary);
    padding: 6px 12px;
    border-radius: var(--border-radius-button);
    font-size: 0.9em;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all var(--transition-speed);
}

#fullTemplateViewModal .modal-header-bottom-row .issue-tag i {
    color: var(--text-dark-secondary);
}

#fullTemplateViewModal .modal-header-bottom-row .smart-tag { /* Style for smart tag in modal header */
    background-color: var(--input-bg);
    border: 1px solid var(--warning-yellow);
    color: var(--warning-yellow);
    padding: 6px 12px;
    border-radius: var(--border-radius-button);
    font-size: 0.9em;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(255,193,7,0.15);
}
#fullTemplateViewModal .modal-header-bottom-row .smart-tag i {
    font-size: 0.9em;
}

#fullTemplateViewModal .modal-header-bottom-row .keywords-tag { /* Style for keywords tag in modal header */
    background-color: var(--input-bg);
    color: var(--text-dark-secondary);
    padding: 6px 12px;
    border-radius: var(--border-radius-button);
    font-size: 0.9em;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
#fullTemplateViewModal .modal-header-bottom-row .keywords-tag i {
    color: var(--text-dark-secondary);
}


#fullTemplateViewModal .modal-body { /* New wrapper for scrollable content */
    flex-grow: 1; /* Allow it to take available space */
    background-color: var(--input-bg);
    border-radius: var(--border-radius-main);
    padding: 25px;
    margin-bottom: 25px;
    max-height: 400px; /* Limit height and make scrollable */
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

#fullTemplateViewModal .modal-body p {
    margin: 0;
    color: var(--text-light);
    line-height: 1.8;
    font-size: 1.1em;
    white-space: pre-wrap; /* Preserve line breaks and spaces */
    word-wrap: break-word; /* Break long words */
}

/* Custom Scrollbar for modal content */
#fullTemplateViewModal .modal-body::-webkit-scrollbar { /* Changed from .modal-template-content-scroll */
    width: 8px;
}
#fullTemplateViewModal .modal-body::-webkit-scrollbar-track { /* Changed from .modal-template-content-scroll */
    background: var(--bg-dark);
    border-radius: 10px;
}
#fullTemplateViewModal .modal-body::-webkit-scrollbar-thumb { /* Changed from .modal-template-content-scroll */
    background-color: var(--text-dark-secondary);
    border-radius: 10px;
    border: 2px solid var(--input-bg);
}
#fullTemplateViewModal .modal-body::-webkit-scrollbar-thumb:hover { /* Changed from .modal-template-content-scroll */
    background-color: var(--accent-blue-green);
}

/* Remove these if the tags are handled within modal-header-bottom-row */
/* #fullTemplateViewModal .modal-template-tags {
    display: none;
} */


#fullTemplateViewModal .copy-button {
    width: 100%;
    padding: 15px 30px;
    font-size: 1.1em;
    margin-top: auto; /* Push button to the bottom */
}

/* --- Footer Styles --- */
.main-footer {
    background-color: var(--container-bg);
    color: var(--text-dark-secondary);
    padding: 30px 20px;
    text-align: center;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.main-footer p {
    margin: 0;
    font-size: 1.05em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.main-footer p .fas.fa-heart {
    color: var(--accent-red);
    font-size: 1.2em;
    animation: pulse 1.5s infinite ease-in-out;
}

/* Telegram Link Animation */
.telegram-link {
    background-color: #0088CC;
    color: white;
    padding: 12px 25px;
    border-radius: var(--border-radius-button);
    text-decoration: none;
    font-size: 1.1em;
    font-weight: 600;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease-out;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.3);
    width: fit-content;
}

.telegram-link i {
    font-size: 1.5em;
    transition: transform 0.3s ease-out;
}

.telegram-link .telegram-text {
    max-width: 0;
    opacity: 0;
    transition: max-width 0.3s ease-out, opacity 0.3s ease-out;
    white-space: nowrap;
}

.telegram-link:hover {
    background-color: #0077B3;
    box-shadow: 0 6px 20px rgba(0, 136, 204, 0.5);
}

.telegram-link:hover .telegram-text {
    max-width: 200px;
    opacity: 1;
}

.telegram-link:hover i {
    transform: translateX(-5px);
}

/* Keyframes for animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* New keyframes for flash messages */
@keyframes flashShow {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes flashHide {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-30px); }
}

.flashes li.show {
    animation: flashShow 0.4s forwards;
}

.flashes li.hide {
    animation: flashHide 0.5s forwards;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Media queries for responsiveness */
@media (max-width: 1200px) {
    .template-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
    }
}

@media (max-width: 992px) {
    main {
        max-width: 960px;
        padding: 0 20px;
    }
    .template-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    .template-card {
        padding: 24px;
        min-height: 220px; /* Adjust min-height for smaller screens */
    }
    .template-header-top-row .template-title {
        font-size: 1.3em;
    }
    header {
        padding: 15px 30px;
    }
    header h1 {
        font-size: 2em;
    }
    .welcome-message {
        font-size: 1em;
    }
}

@media (max-width: 768px) {
    main {
        max-width: 720px;
        padding: 0 15px;
        margin: 25px auto;
    }
    .template-list {
        grid-template-columns: 1fr; /* Single column on smaller screens */
        gap: 15px;
    }
    .template-card {
        min-height: auto; /* Allow height to adapt on single column layout */
    }
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 15px;
    }
    .header-right {
        width: 100%;
        justify-content: flex-end;
        gap: 10px;
    }
    .button {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    .search-container {
        margin-bottom: 25px;
    }
    #searchInput {
        padding: 12px 20px;
        font-size: 1em;
    }
    .template-actions {
        top: 15px;
        right: 15px;
        gap: 8px;
    }
    .template-actions .action-button {
        width: 32px;
        height: 32px;
    }
    .template-actions .action-button i {
        font-size: 15px;
    }
    .modal-content {
        padding: 25px;
        max-width: 95%;
    }
    .modal-content h2 {
        font-size: 1.6em;
        margin-bottom: 20px;
    }
    .close-button {
        font-size: 30px;
        top: 15px;
        right: 18px;
    }
    /* Smart template modal specific adjustments */
    .smart-template-hint-box {
        padding: 15px;
        gap: 10px;
    }
    .smart-template-hint-box i {
        font-size: 1.8em;
    }
    .smart-template-hint-box p {
        font-size: 0.9em;
    }
    /* Full template view modal specific adjustments */
    #fullTemplateViewModal .modal-content {
        padding: 25px;
    }
    #fullTemplateViewModal .modal-header-top-row .template-type {
        font-size: 0.8em; /* Smaller font for type in modal on small screens */
    }
    #fullTemplateViewModal .template-title-full {
        font-size: 1.8em;
        margin-bottom: 18px;
    }
    #fullTemplateViewModal .modal-header-bottom-row {
        gap: 8px; /* Slightly smaller gap */
    }
    #fullTemplateViewModal .modal-header-bottom-row .issue-tag,
    #fullTemplateViewModal .modal-header-bottom-row .smart-tag,
    #fullTemplateViewModal .modal-header-bottom-row .keywords-tag {
        font-size: 0.8em; /* Smaller font for tags in modal on small screens */
        padding: 5px 10px;
    }
    #fullTemplateViewModal .modal-body {
        padding: 18px;
        max-height: 300px;
    }
    #fullTemplateViewModal .modal-body p {
        font-size: 1em;
    }
    #fullTemplateViewModal .copy-button {
        padding: 12px 25px;
        font-size: 1em;
    }
    /* Footer */
    .main-footer {
        padding: 20px 15px;
        gap: 10px;
    }
    .main-footer p {
        font-size: 0.95em;
    }
    .telegram-link {
        padding: 10px 20px;
        font-size: 1em;
    }
    .telegram-link i {
        font-size: 1.3em;
    }
}

@media (max-width: 480px) {
    .template-list {
        grid-template-columns: 1fr; /* Single column on very small screens too */
    }
    .header-right {
        flex-direction: column;
        width: auto;
        align-items: flex-end;
    }
    .button {
        width: fit-content;
    }
    .form-container {
        padding: 25px;
        margin: 30px 15px;
    }
    .form-container h1 {
        font-size: 2em;
    }
}