/* ===================================
   TEMPLATES PAGE - PREMIUM DESIGN
   TodoSign Design System v2.0
   Cyan/Indigo Theme with Glassmorphism
=================================== */
@import url('theme.css');

/* ==================== CSS CUSTOM PROPERTIES ==================== */
:root {
    /* Typography - Premium Fonts (use global) */
    --tpl-font-display: var(--font-display);
    --tpl-font-body: var(--font-body);

    /* Color Palette - Cyan/Indigo Theme (using global tokens) */
    --tpl-cyan-50: var(--cyan-50);
    --tpl-cyan-100: var(--cyan-100);
    --tpl-cyan-200: var(--cyan-200);
    --tpl-cyan-300: var(--cyan-300);
    --tpl-cyan-400: var(--cyan-400);
    --tpl-cyan-500: var(--cyan-500);
    --tpl-cyan-600: var(--cyan-600);
    --tpl-cyan-700: var(--cyan-700);
    --tpl-cyan-800: var(--cyan-800);
    --tpl-cyan-900: var(--cyan-900);

    /* Accent Colors */
    --tpl-accent-primary: var(--cyan-500);
    --tpl-accent-secondary: var(--indigo-500);
    --tpl-accent-amber: #f59e0b;
    --tpl-accent-blue: #06b6d4;
    --tpl-accent-purple: #6366f1;

    /* Navy Backgrounds (use global) */
    --tpl-navy-deep: var(--navy-950);
    --tpl-navy-dark: var(--navy-900);
    --tpl-navy-medium: var(--navy-800);
    --tpl-navy-light: var(--slate-600);

    /* Glassmorphism (use global) */
    --tpl-glass-bg: var(--glass-bg);
    --tpl-glass-bg-hover: var(--glass-bg-hover);
    --tpl-glass-border: var(--glass-border);
    --tpl-glass-border-hover: var(--glass-border-hover);
    --tpl-backdrop-blur: var(--glass-blur);
    --tpl-backdrop-blur-strong: blur(40px);

    /* Text Colors (use global) */
    --tpl-text-primary: var(--text-primary);
    --tpl-text-secondary: var(--text-secondary);
    --tpl-text-muted: var(--text-muted);

    /* Shadows - Multi-layer System */
    --tpl-shadow-ambient: 0 0 60px rgba(6, 182, 212, 0.06);
    --tpl-shadow-depth: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    --tpl-shadow-card: var(--shadow-card);
    --tpl-shadow-card-hover:
        0 20px 40px -15px rgba(0, 0, 0, 0.3),
        0 0 60px rgba(6, 182, 212, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    --tpl-shadow-glow: 0 0 30px rgba(6, 182, 212, 0.25);

    /* Transitions (use global) */
    --tpl-transition: var(--transition-normal);
    --tpl-transition-fast: var(--transition-fast);
    --tpl-transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    --tpl-transition-spring: var(--transition-spring);

    /* Spacing & Radius (use global) */
    --tpl-radius-sm: var(--radius-sm);
    --tpl-radius-md: var(--radius-md);
    --tpl-radius-lg: var(--radius-lg);
    --tpl-radius-xl: var(--radius-xl);
    --tpl-radius-full: var(--radius-full);
}

/* ==================== KEYFRAME ANIMATIONS ==================== */
@keyframes tpl-slide-up {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tpl-card-enter {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes tpl-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tpl-scale-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes tpl-float-glow {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.12;
    }
    33% {
        transform: translate(30px, -20px) scale(1.05);
        opacity: 0.18;
    }
    66% {
        transform: translate(-20px, 20px) scale(0.95);
        opacity: 0.1;
    }
}

@keyframes tpl-pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(6, 182, 212, 0.2);
    }
    50% {
        box-shadow: 0 0 35px rgba(6, 182, 212, 0.35);
    }
}

@keyframes tpl-shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

@keyframes tpl-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes tpl-star-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

@keyframes tpl-float-doc {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(3deg); }
}

/* ==================== AMBIENT GLOW EFFECTS ==================== */
.ambient-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
    animation: tpl-float-glow 20s ease-in-out infinite;
}

.ambient-glow-1 {
    top: -200px;
    right: 10%;
    background: linear-gradient(135deg, var(--cyan-500) 0%, var(--indigo-500) 100%);
}

.ambient-glow-2 {
    bottom: -200px;
    left: 10%;
    background: linear-gradient(135deg, var(--indigo-500) 0%, var(--cyan-500) 100%);
    animation-delay: -10s;
}

/* ==================== LAYOUT ==================== */
.container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2.5rem 2.5rem;
    overflow-y: auto;
    font-family: var(--tpl-font-body);
    animation: tpl-fade-in 0.6s ease-out;
}

/* Header styles moved to /css/header.css (Floating Glass Header) */

/* Hero styles moved to /css/hero.css (Glass Card Premium) */

/* ==================== STATS BAR ==================== */
.stats-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    animation: tpl-slide-up 0.6s ease-out 0.2s both;
}

.stat-pill {
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 22px;
    background: var(--tpl-glass-bg);
    border: 1px solid var(--tpl-glass-border);
    border-radius: var(--tpl-radius-lg);
    backdrop-filter: var(--tpl-backdrop-blur);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur);
    transition: all var(--tpl-transition);
    box-shadow: var(--tpl-shadow-card);
}

.stat-pill:hover {
    transform: translateY(-4px);
    box-shadow: var(--tpl-shadow-card-hover);
    border-color: var(--tpl-glass-border-hover);
}

.stat-pill-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--tpl-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--tpl-transition);
}

.stat-pill-content {
    display: flex;
    flex-direction: column;
}

.stat-pill-value {
    font-family: var(--tpl-font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--tpl-text-primary);
    line-height: 1;
}

.stat-pill-label {
    font-size: 0.8rem;
    color: var(--tpl-text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

/* Stat Pill Color Variants */
.stat-pill-cyan .stat-pill-icon,
.stat-pill-emerald .stat-pill-icon {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(6, 182, 212, 0.08));
    color: var(--cyan-400);
}

.stat-pill-cyan:hover,
.stat-pill-emerald:hover {
    border-color: rgba(6, 182, 212, 0.4);
    background: rgba(6, 182, 212, 0.05);
}

.stat-pill-cyan:hover .stat-pill-icon,
.stat-pill-emerald:hover .stat-pill-icon {
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.stat-pill-amber .stat-pill-icon {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.08));
    color: var(--tpl-accent-amber);
}

.stat-pill-amber:hover {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.05);
}

.stat-pill-amber:hover .stat-pill-icon {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.stat-pill-blue .stat-pill-icon {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.08));
    color: var(--tpl-accent-blue);
}

.stat-pill-blue:hover {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.05);
}

.stat-pill-blue:hover .stat-pill-icon {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.stat-pill-purple .stat-pill-icon {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.08));
    color: var(--tpl-accent-purple);
}

.stat-pill-purple:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.05);
}

.stat-pill-purple:hover .stat-pill-icon {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* ==================== FILTERS BAR ==================== */
.filters-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
    background: transparent;
    animation: tpl-slide-up 0.6s ease-out 0.3s both;
}

.filters-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--tpl-glass-bg);
    padding: 4px;
    border-radius: var(--tpl-radius-md);
    border: 1px solid var(--tpl-glass-border);
    backdrop-filter: var(--tpl-backdrop-blur);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur);
}

.view-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--tpl-text-secondary);
    border-radius: var(--tpl-radius-sm);
    cursor: pointer;
    transition: all var(--tpl-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.view-btn:hover {
    color: var(--tpl-text-primary);
    background: var(--tpl-glass-bg-hover);
}

.view-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 12px rgba(6, 182, 212, 0.4);
}

.hero-actions .view-btn.active {
    background: var(--gradient-primary);
    box-shadow: 0 2px 12px rgba(6, 182, 212, 0.4);
}

/* Filter styles moved to /css/filters.css */

/* ==================== PRIMARY BUTTON ==================== */
.btn-primary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px !important;
    background: var(--gradient-primary) !important;
    border: none !important;
    border-radius: var(--tpl-radius-md) !important;
    color: white !important;
    font-family: var(--tpl-font-body);
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all var(--tpl-transition);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.35) !important;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.45) !important;
    background: var(--gradient-primary-hover) !important;
}

.btn-primary i {
    font-size: 1rem;
}

/* ==================== TEMPLATES GRID ==================== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    animation: tpl-slide-up 0.6s ease-out 0.4s both;
}

/* ==================== TEMPLATE CARD ==================== */
.template-card {
    background: var(--tpl-glass-bg);
    border-radius: var(--tpl-radius-xl);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--tpl-transition);
    display: flex;
    flex-direction: column;
    box-shadow: var(--tpl-shadow-card);
    border: 1px solid var(--tpl-glass-border);
    position: relative;
    height: 220px;
    animation: tpl-card-enter 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
    backdrop-filter: var(--tpl-backdrop-blur);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur);
}

/* Staggered Animation */
.template-card:nth-child(1) { animation-delay: 0.05s; }
.template-card:nth-child(2) { animation-delay: 0.1s; }
.template-card:nth-child(3) { animation-delay: 0.15s; }
.template-card:nth-child(4) { animation-delay: 0.2s; }
.template-card:nth-child(5) { animation-delay: 0.25s; }
.template-card:nth-child(6) { animation-delay: 0.3s; }
.template-card:nth-child(7) { animation-delay: 0.35s; }
.template-card:nth-child(8) { animation-delay: 0.4s; }

.template-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--tpl-shadow-card-hover);
    border-color: rgba(6, 182, 212, 0.4);
}

/* Card Header - Preview Area */
.template-header-preview {
    height: 130px;
    background: linear-gradient(135deg, var(--cyan-800) 0%, var(--cyan-900) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--tpl-transition);
    overflow: hidden;
}

.template-header-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.2) 100%);
}

.template-card:hover .template-header-preview {
    height: 110px;
    background: linear-gradient(135deg, var(--cyan-700) 0%, var(--indigo-800) 100%);
}

.template-icon-large {
    font-size: 3.5rem;
    color: var(--cyan-300);
    filter: drop-shadow(0 4px 10px rgba(6, 182, 212, 0.4));
    transition: all var(--tpl-transition-spring);
    position: relative;
    z-index: 1;
}

.template-card:hover .template-icon-large {
    transform: scale(1.15) rotate(-5deg);
    filter: drop-shadow(0 8px 20px rgba(6, 182, 212, 0.5));
    color: var(--cyan-200);
}

/* Card Body */
.template-body {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--tpl-navy-dark);
    position: relative;
    z-index: 2;
}

.template-name {
    font-family: var(--tpl-font-body);
    font-weight: 700;
    color: var(--tpl-text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color var(--tpl-transition);
}

.template-card:hover .template-name {
    color: var(--cyan-300);
}

.template-meta {
    font-family: var(--tpl-font-body);
    font-size: 0.85rem;
    color: var(--tpl-text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.template-meta i {
    font-size: 0.8rem;
    color: var(--cyan-400);
}

/* Actions Overlay */
.template-actions-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all var(--tpl-transition);
    z-index: 5;
}

.template-card:hover .template-actions-overlay {
    opacity: 1;
    transform: translateY(0);
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--tpl-radius-full);
    background: rgba(255, 255, 255, 0.95);
    color: var(--tpl-text-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--tpl-transition);
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.action-btn:hover {
    background: var(--cyan-500);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

.action-btn.delete-btn:hover {
    background: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Favorite Button */
.favorite-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    border-radius: var(--tpl-radius-full);
    background: rgba(255, 255, 255, 0.95);
    color: var(--tpl-text-muted);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--tpl-transition);
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 5;
}

.favorite-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
}

.favorite-btn.active {
    color: var(--tpl-accent-amber);
    background: rgba(255, 255, 255, 1);
}

.favorite-btn.active i {
    animation: tpl-star-pop 0.4s ease;
}

/* ==================== LIST VIEW ==================== */
.templates-list-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-item-template {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 22px;
    background: var(--tpl-glass-bg);
    border: 1px solid var(--tpl-glass-border);
    border-radius: var(--tpl-radius-lg);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--tpl-transition);
    animation: tpl-card-enter 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
    backdrop-filter: var(--tpl-backdrop-blur);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur);
}

/* Side Accent Border */
.list-item-template::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, var(--cyan-400) 0%, var(--indigo-500) 100%);
    border-radius: 0 3px 3px 0;
    transition: height var(--tpl-transition);
}

/* Glow Effect */
.list-item-template::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at left center, rgba(6, 182, 212, 0.06) 0%, transparent 60%);
    opacity: 0;
    transition: opacity var(--tpl-transition);
    pointer-events: none;
}

.list-item-template:hover {
    background: var(--tpl-glass-bg-hover);
    border-color: var(--tpl-glass-border-hover);
    transform: translateY(-2px);
    box-shadow: var(--tpl-shadow-card-hover);
}

.list-item-template:hover::before {
    height: 60%;
}

.list-item-template:hover::after {
    opacity: 1;
}

/* List Item Icon */
.templates-list-view .list-item-icon {
    position: relative;
    flex-shrink: 0;
}

.templates-list-view .list-item-icon > i {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--cyan-400);
    background: linear-gradient(145deg, rgba(6, 182, 212, 0.12) 0%, rgba(8, 145, 178, 0.06) 100%);
    border-radius: var(--tpl-radius-md);
    border: 1px solid rgba(6, 182, 212, 0.1);
    transition: all var(--tpl-transition);
}

.list-item-template:hover .list-item-icon > i {
    background: linear-gradient(145deg, var(--cyan-400) 0%, var(--indigo-500) 100%);
    color: #ffffff;
    transform: scale(1.06) rotate(-3deg);
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.35);
    border-color: transparent;
}

/* List Item Content */
.templates-list-view .list-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.templates-list-view .list-item-name {
    font-family: var(--tpl-font-body);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--tpl-text-primary);
    letter-spacing: -0.01em;
    transition: color var(--tpl-transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-template:hover .list-item-name {
    color: var(--cyan-300);
}

.templates-list-view .list-item-meta {
    font-family: var(--tpl-font-body);
    font-size: 0.82rem;
    color: var(--tpl-text-secondary);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: color var(--tpl-transition);
}

.templates-list-view .list-item-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.templates-list-view .list-item-meta i {
    font-size: 0.75rem;
    color: rgba(6, 182, 212, 0.6);
}

.list-item-template:hover .list-item-meta {
    color: var(--tpl-text-primary);
}

/* List Item Favorite Badge */
.templates-list-view .favorite-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--tpl-radius-full);
    font-family: var(--tpl-font-body);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all var(--tpl-transition);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--tpl-glass-border);
    color: var(--tpl-text-secondary);
    cursor: pointer;
}

.templates-list-view .favorite-badge:hover {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
    color: var(--tpl-accent-amber);
    transform: translateY(-1px);
}

.templates-list-view .favorite-badge.active {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, rgba(245, 158, 11, 0.1) 100%);
    border-color: rgba(251, 191, 36, 0.4);
    color: var(--tpl-accent-amber);
}

.templates-list-view .favorite-badge.active i {
    color: var(--tpl-accent-amber);
}

/* List Item Actions */
.templates-list-view .list-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--tpl-transition);
}

.templates-list-view .list-item-actions .action-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--tpl-radius-md);
    border: 1px solid var(--tpl-glass-border);
    background: var(--tpl-glass-bg);
    color: var(--tpl-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--tpl-transition);
    font-size: 0.8rem;
}

.templates-list-view .list-item-actions .action-btn:hover {
    transform: translateY(-2px) scale(1.05);
}

.templates-list-view .list-item-actions .edit-btn:hover {
    background: linear-gradient(145deg, rgba(6, 182, 212, 0.18) 0%, rgba(8, 145, 178, 0.1) 100%);
    border-color: rgba(6, 182, 212, 0.45);
    color: var(--cyan-400);
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.2);
}

.templates-list-view .list-item-actions .delete-btn:hover {
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.18) 0%, rgba(220, 38, 38, 0.1) 100%);
    border-color: rgba(239, 68, 68, 0.45);
    color: #f87171;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.2);
}

/* ==================== LEGACY TABLE VIEW ==================== */
.templates-list-container {
    background: var(--tpl-glass-bg);
    border: 1px solid var(--tpl-glass-border);
    border-radius: var(--tpl-radius-lg);
    overflow: hidden;
    box-shadow: var(--tpl-shadow-card);
    backdrop-filter: var(--tpl-backdrop-blur);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur);
}

.templates-table-header {
    display: grid;
    grid-template-columns: 50px 1fr 120px 100px 120px;
    gap: 1rem;
    padding: 16px 20px;
    background: var(--tpl-glass-bg-hover);
    border-bottom: 1px solid var(--tpl-glass-border);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tpl-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.template-row {
    display: grid;
    grid-template-columns: 50px 1fr 120px 100px 120px;
    gap: 1rem;
    padding: 16px 20px;
    border-bottom: 1px solid var(--tpl-glass-border);
    transition: background var(--tpl-transition);
    align-items: center;
    cursor: pointer;
}

.template-row:hover {
    background: var(--tpl-glass-bg-hover);
}

.template-row:last-child {
    border-bottom: none;
}

.template-icon-small {
    width: 40px;
    height: 40px;
    border-radius: var(--tpl-radius-md);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(6, 182, 212, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cyan-400);
}

.template-name-text {
    color: var(--tpl-text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    display: block;
}

.var-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(6, 182, 212, 0.1);
    color: var(--cyan-400);
    border-radius: 6px;
    font-size: 0.8rem;
}

.col-date {
    color: var(--tpl-text-secondary);
    font-size: 0.9rem;
}

.col-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.template-row .action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--tpl-glass-bg);
    color: var(--tpl-text-secondary);
    border-radius: var(--tpl-radius-sm);
    cursor: pointer;
    transition: all var(--tpl-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-row .action-btn:hover {
    background: var(--tpl-glass-bg-hover);
    color: var(--tpl-text-primary);
}

.template-row .favorite-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--tpl-text-secondary);
    border-radius: var(--tpl-radius-sm);
    cursor: pointer;
    transition: all var(--tpl-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-row .favorite-btn:hover,
.template-row .favorite-btn.active {
    color: var(--tpl-accent-amber);
}

/* ==================== LOADING & EMPTY STATES ==================== */
.loading-state,
.empty-state,
.error-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--tpl-text-secondary);
    gap: 1rem;
    text-align: center;
    background: var(--tpl-glass-bg);
    border: 1px solid var(--tpl-glass-border);
    border-radius: var(--tpl-radius-xl);
    backdrop-filter: var(--tpl-backdrop-blur);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur);
}

.loading-state i,
.empty-state .empty-icon i,
.error-state .error-icon i {
    font-size: 3rem;
    color: var(--cyan-400);
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.error-state .error-icon i {
    color: #ef4444;
}

.empty-state h3,
.error-state h3 {
    font-family: var(--tpl-font-display);
    font-size: 1.3rem;
    color: var(--tpl-text-primary);
    margin: 0;
}

.empty-state p,
.error-state p {
    font-family: var(--tpl-font-body);
    font-size: 0.95rem;
    color: var(--tpl-text-secondary);
    max-width: 300px;
    line-height: 1.5;
}

.empty-state .btn-primary,
.error-state .btn-primary {
    margin-top: 1rem;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner i {
    font-size: 2rem;
    color: var(--cyan-400);
    animation: tpl-spin 1s linear infinite;
}

/* ==================== MODAL STYLES ==================== */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.custom-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: var(--tpl-backdrop-blur);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur);
    animation: tpl-fade-in 0.3s ease-out;
    z-index: 1 !important;
}

.custom-modal .modal-dialog {
    position: relative;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: var(--tpl-backdrop-blur-strong);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur-strong);
    width: 100%;
    max-width: 550px;
    border-radius: var(--tpl-radius-xl);
    box-shadow: var(--tpl-shadow-depth);
    border: 1px solid rgba(226, 232, 240, 0.8);
    z-index: 10 !important;
    animation: tpl-scale-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.9) 100%);
    border-radius: var(--tpl-radius-xl) var(--tpl-radius-xl) 0 0;
}

.modal-header h3 {
    font-family: var(--tpl-font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    letter-spacing: -0.02em;
}

.modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    width: 36px;
    height: 36px;
    border-radius: var(--tpl-radius-sm);
    cursor: pointer;
    transition: all var(--tpl-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: none;
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
    background: transparent;
}

.modal-body p {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-footer {
    padding: 24px 32px;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(248, 250, 252, 0.5);
    border-radius: 0 0 var(--tpl-radius-xl) var(--tpl-radius-xl);
}

/* Form Styles */
.variables-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
    margin-left: 4px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--tpl-radius-md);
    color: #1e293b;
    outline: none;
    transition: all var(--tpl-transition);
    font-size: 0.95rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.form-input::placeholder {
    color: #94a3b8;
    opacity: 0.8;
}

.form-input:focus {
    border-color: var(--cyan-500);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

/* Modal Buttons */
.modal-btn {
    padding: 12px 24px;
    border-radius: var(--tpl-radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--tpl-transition);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.modal-btn.btn-secondary {
    background: transparent;
    color: #64748b;
    border: 1px solid transparent;
}

.modal-btn.btn-secondary:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.modal-btn.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 6px rgba(6, 182, 212, 0.25);
}

.modal-btn.btn-primary:hover {
    background: var(--gradient-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(6, 182, 212, 0.3);
}

/* ==================== SUCCESS TOAST ==================== */
.success-toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: var(--tpl-backdrop-blur);
    -webkit-backdrop-filter: var(--tpl-backdrop-blur);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-left: 4px solid var(--cyan-500);
    padding: 16px 24px;
    border-radius: var(--tpl-radius-md);
    box-shadow: var(--tpl-shadow-depth);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--tpl-transition-spring);
    z-index: 3000;
}

.success-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.success-toast i {
    color: var(--cyan-500);
    font-size: 1.4rem;
}

.success-toast span {
    color: var(--tpl-text-primary);
    font-weight: 600;
    font-size: 1rem;
}

/* ==================== ACCESSIBILITY ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .ambient-glow {
        animation: none;
    }

    .floating-doc {
        animation: none;
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
        padding: 1.25rem;
    }

    .hero-title {
        font-size: 2rem;
    }

    .stats-bar {
        gap: 0.5rem;
    }

    .stat-pill {
        min-width: 140px;
        padding: 14px 18px;
    }
}

@media (max-width: 768px) {
    .top-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .search-container {
        flex: 1;
        max-width: none;
    }

    .hero-welcome {
        flex-direction: column;
        gap: 1rem;
    }

    .hero-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .filters-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters-bar-right {
        width: 100%;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .templates-grid {
        grid-template-columns: 1fr;
    }

    .templates-list-view {
        gap: 10px;
    }

    .list-item-template {
        padding: 14px 16px;
        gap: 14px;
        border-radius: var(--tpl-radius-md);
    }

    .templates-list-view .list-item-icon > i {
        width: 42px;
        height: 42px;
        font-size: 1.05rem;
        border-radius: var(--tpl-radius-md);
    }

    .templates-list-view .list-item-name {
        font-size: 0.9rem;
    }

    .templates-list-view .list-item-meta {
        font-size: 0.78rem;
        flex-wrap: wrap;
        gap: 8px;
    }

    .templates-list-view .list-item-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .templates-list-view .list-item-actions .action-btn {
        width: 34px;
        height: 34px;
        font-size: 0.75rem;
    }

    .templates-list-view .favorite-badge {
        padding: 6px 10px;
        font-size: 0.7rem;
    }
}

/* ==================== LIGHT THEME ==================== */
[data-theme="light"] {
    --tpl-text-primary: #0f172a;
    --tpl-text-secondary: #64748b;
    --tpl-text-muted: #94a3b8;
    --tpl-glass-bg: rgba(255, 255, 255, 0.8);
    --tpl-glass-bg-hover: rgba(255, 255, 255, 0.95);
    --tpl-glass-border: rgba(0, 0, 0, 0.06);
    --tpl-glass-border-hover: rgba(0, 0, 0, 0.12);
    --tpl-shadow-card:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 1px 2px rgba(0, 0, 0, 0.03);
    --tpl-shadow-card-hover:
        0 20px 50px rgba(0, 0, 0, 0.12),
        0 8px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .hero-title {
    background: linear-gradient(135deg, var(--light-text-primary) 0%, var(--cyan-600) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="light"] .greeting-label {
    color: var(--cyan-600);
}

[data-theme="light"] .template-body {
    background: #ffffff;
}

[data-theme="light"] .template-header-preview {
    background: linear-gradient(135deg, var(--cyan-100) 0%, var(--cyan-200) 100%);
}

[data-theme="light"] .template-card:hover .template-header-preview {
    background: linear-gradient(135deg, var(--cyan-200) 0%, var(--indigo-200) 100%);
}

[data-theme="light"] .template-icon-large {
    color: var(--cyan-600);
}

[data-theme="light"] .template-card:hover .template-icon-large {
    color: var(--cyan-500);
}

[data-theme="light"] .template-card:hover .template-name {
    color: var(--cyan-700);
}

/* Light Mode - List View */
[data-theme="light"] .list-item-template {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.95) 100%);
    border-color: rgba(226, 232, 240, 0.6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .list-item-template:hover {
    background: #ffffff !important;
    border-color: rgba(226, 232, 240, 1);
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.12),
        0 8px 20px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(226, 232, 240, 0.8);
}

[data-theme="light"] .list-item-template::after {
    background: radial-gradient(ellipse at left center, rgba(207, 250, 254, 0.5) 0%, transparent 60%);
}

[data-theme="light"] .templates-list-view .list-item-icon > i {
    background: linear-gradient(145deg, rgba(6, 182, 212, 0.15) 0%, rgba(8, 145, 178, 0.1) 100%);
    border-color: rgba(6, 182, 212, 0.2);
    color: var(--cyan-600);
}

[data-theme="light"] .list-item-template:hover .list-item-icon > i {
    background: linear-gradient(145deg, var(--cyan-400) 0%, var(--indigo-500) 100%);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.35);
}

[data-theme="light"] .templates-list-view .list-item-name {
    color: #1e293b;
}

[data-theme="light"] .list-item-template:hover .list-item-name {
    color: var(--cyan-700);
}

[data-theme="light"] .templates-list-view .list-item-meta {
    color: #64748b;
}

[data-theme="light"] .templates-list-view .list-item-meta i {
    color: var(--cyan-500);
}

[data-theme="light"] .list-item-template:hover .list-item-meta {
    color: #334155;
}

[data-theme="light"] .templates-list-view .favorite-badge {
    background: rgba(248, 250, 252, 0.9);
    border-color: rgba(226, 232, 240, 0.7);
    color: #64748b;
}

[data-theme="light"] .templates-list-view .favorite-badge:hover {
    background: linear-gradient(145deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
    color: #b45309;
}

[data-theme="light"] .templates-list-view .favorite-badge.active {
    background: linear-gradient(145deg, #fef3c7 0%, #fde68a 100%);
    border-color: rgba(245, 158, 11, 0.5);
    color: #b45309;
}

[data-theme="light"] .templates-list-view .list-item-actions .action-btn {
    background: rgba(248, 250, 252, 0.9);
    border-color: rgba(226, 232, 240, 0.7);
    color: #64748b;
}

[data-theme="light"] .templates-list-view .list-item-actions .edit-btn:hover {
    background: linear-gradient(145deg, #cffafe 0%, #a5f3fc 100%);
    border-color: var(--cyan-500);
    color: var(--cyan-700);
}

[data-theme="light"] .templates-list-view .list-item-actions .delete-btn:hover {
    background: linear-gradient(145deg, #fee2e2 0%, #fecaca 100%);
    border-color: #ef4444;
    color: #b91c1c;
}

/* Light Mode - Empty State */
[data-theme="light"] .empty-state,
[data-theme="light"] .error-state,
[data-theme="light"] .loading-state {
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .empty-state .empty-icon i {
    color: var(--cyan-500);
    opacity: 0.7;
}

[data-theme="light"] .empty-state h3,
[data-theme="light"] .error-state h3 {
    color: #0f172a;
}

[data-theme="light"] .empty-state p,
[data-theme="light"] .error-state p {
    color: #64748b;
}

/* Light Mode - Inputs */
[data-theme="light"] .search-input {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
    color: #0f172a;
}

[data-theme="light"] .search-input:focus {
    background: #ffffff;
    border-color: var(--cyan-500);
}

[data-theme="light"] .search-input::placeholder {
    color: #94a3b8;
}

[data-theme="light"] .search-shortcut {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.06);
    color: #64748b;
}

/* Light Mode - Stat Pills */
[data-theme="light"] .stat-pill {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .stat-pill:hover {
    background: #ffffff;
}

[data-theme="light"] .stat-pill-value {
    color: #0f172a;
}

[data-theme="light"] .stat-pill-label {
    color: #64748b;
}

/* Light Mode - Template Cards */
[data-theme="light"] .template-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .template-card:hover {
    background: #ffffff;
    border-color: rgba(6, 182, 212, 0.3);
}

[data-theme="light"] .template-name {
    color: #0f172a;
}

[data-theme="light"] .template-meta {
    color: #64748b;
}

/* Light Mode - Filters */
[data-theme="light"] .filter-group {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .filter-btn {
    color: #64748b;
}

[data-theme="light"] .filter-btn:hover {
    color: #0f172a;
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .filter-btn.active {
    background: var(--gradient-primary);
    color: white !important;
}

[data-theme="light"] .filter-btn.active i,
[data-theme="light"] .filter-btn.active span {
    color: white !important;
}

[data-theme="light"] .filter-btn.active .filter-count {
    background: rgba(255, 255, 255, 0.25);
    color: white !important;
}

[data-theme="light"] .filter-count {
    background: rgba(6, 182, 212, 0.1);
    color: var(--cyan-600);
}

/* Light Mode - View Toggle */
[data-theme="light"] .view-toggle {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .view-btn {
    color: #64748b;
}

[data-theme="light"] .view-btn:hover {
    color: #0f172a;
    background: rgba(0, 0, 0, 0.04);
}

/* Light Mode - Icon Buttons */
[data-theme="light"] .icon-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.06);
    color: #64748b;
}

[data-theme="light"] .icon-btn:hover {
    background: #ffffff;
    color: #0f172a;
}

/* Light Mode - Theme Toggle */
[data-theme="light"] .theme-toggle {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .theme-toggle:hover {
    background: #ffffff;
}

/* Light Mode - Toast */
[data-theme="light"] .success-toast {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(6, 182, 212, 0.2);
}

[data-theme="light"] .success-toast span {
    color: #0f172a;
}
