/* ============================================
   MINIATURIZED AUTOMATION CARDS - Phase 3
   150px height | 1/4 scale | Modal expansion
   ============================================ */

.automation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin: 2rem auto;
    padding: 0 1.5rem;
    max-width: 1400px;
}

/* Responsive automation card */
.automation-card {
    background: linear-gradient(135deg, var(--bg-lightest, #F8FAFB) 0%, white 100%);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 0.75rem;
    padding: 1.25rem;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.automation-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--refined-purple, #6366f1), var(--accent-teal, #14b8a6));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.automation-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-strong, 0 8px 24px rgba(15, 23, 42, 0.12));
    border-color: rgba(99, 102, 241, 0.25);
}

.automation-card:hover::before {
    opacity: 1;
}

.automation-card.selected {
    border-color: rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(20, 184, 166, 0.03) 100%);
}

.automation-card.selected::after {
    content: '✓ Configured';
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    padding: 0.125rem 0.375rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.1));
    border-radius: 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    color: #059669;
    letter-spacing: 0.02em;
}

/* Card Header - Compact */
.automation-card .card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--spacing-xs, 0.25rem);
}

.automation-card .card-icon-wrapper {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.automation-card .card-icon {
    width: 48px;
    height: 48px;
    line-height: 1;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.2));
    display: flex;
    align-items: center;
    justify-content: center;
}

.automation-card .card-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* SVG icon styling */
.automation-card svg.card-icon {
    width: 48px;
    height: 48px;
}

.stack-item .item-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stack-item svg.item-icon {
    width: 24px;
    height: 24px;
}

.automation-card .popular-badge {
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.1));
    border-radius: 0.25rem;
    color: #d97706;
    font-weight: 700;
}

/* Card Body - Miniaturized */
.automation-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.automation-card .card-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary, #1A2332);
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.automation-card .card-tagline {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary, #4A5567);
    margin: 0.5rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.automation-card .card-stats {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

.automation-card .stat-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    color: var(--text-tertiary, #6B7280);
}

.automation-card .stat-icon {
    font-size: 0.75rem;
}

.automation-card .stat-value {
    font-weight: 700;
    color: var(--text-primary, #1A2332);
}

.automation-card .stat-label {
    color: var(--text-tertiary, #6B7280);
}

/* Card Footer - Single Configure Button */
.automation-card .card-footer {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.automation-card .btn-expand,
.automation-card .btn-configure {
    flex: 1;
    padding: 0.375rem 0.625rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 0.375rem;
    color: var(--refined-purple, #6366f1);
    font-weight: 600;
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.automation-card .btn-expand:hover,
.automation-card .btn-configure:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

/* ============================================
   MODAL EXPANSION SYSTEM
   ============================================ */

.automation-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 22, 40, 0.75);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg, 1rem);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.automation-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.automation-modal {
    background: linear-gradient(145deg, #0a0f1a 0%, #111827 50%, #1e293b 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 1.5rem;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(99, 102, 241, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transform: scale(0.95) translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide scrollbars */
.automation-modal::-webkit-scrollbar {
    display: none;
}

.automation-modal {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.automation-modal-overlay.active .automation-modal {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.automation-modal-header {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.08) 0%, transparent 100%);
    backdrop-filter: blur(16px);
    color: #e2e8f0;
    padding: 2rem 2rem 1.5rem 2rem;
    border-radius: 1.5rem 1.5rem 0 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    position: relative;
}

.automation-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    border-radius: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ef4444;
    font-size: 1.75rem;
    font-weight: 300;
    transition: all 0.25s ease;
    z-index: 10;
}

.automation-modal-close:hover {
    color: #f87171;
    transform: scale(1.15);
    background: transparent;
}

/* Hide the text fallback icon - show nothing */
.automation-modal-icon {
    display: none !important;
}

.automation-modal-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.automation-modal-tagline {
    font-size: 1rem;
    color: rgba(148, 163, 184, 0.9);
    margin: 0;
    line-height: 1.6;
}

.automation-modal-stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.automation-modal-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: rgba(148, 163, 184, 0.85);
}

.automation-modal-stat strong {
    color: #14b8a6;
    font-weight: 700;
}

/* Modal Body */
.automation-modal-body {
    padding: 2rem;
    color: #e2e8f0;
    overflow-y: auto;
    max-height: 50vh;
}

.automation-modal-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 1rem;
}

.automation-modal-section:last-child {
    margin-bottom: 0;
}

.automation-modal-section-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 1.125rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 0.875rem 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.automation-modal-section-description {
    font-size: 0.95rem;
    line-height: 1.7;
    color: rgba(148, 163, 184, 0.9);
    margin-bottom: 1rem;
}

/* Configuration Toggles */
.config-toggles {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm, 0.5rem);
}

.config-toggle {
    background: linear-gradient(135deg, rgba(51, 65, 85, 0.4) 0%, rgba(30, 41, 59, 0.6) 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-md, 0.5rem);
    padding: var(--spacing-md, 0.75rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s ease;
    backdrop-filter: blur(12px);
}

.config-toggle:hover {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.3), 0 0 20px rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
}

.config-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.config-toggle-title {
    font-size: var(--font-sm, 0.875rem);
    font-weight: 600;
    color: #e2e8f0;
}

.config-toggle-description {
    font-size: 0.75rem;
    color: #94a3b8;
    line-height: 1.4;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(100, 116, 139, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-switch.active {
    background: linear-gradient(135deg, var(--refined-purple, #6366f1), var(--accent-teal, #14b8a6));
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active::after {
    transform: translateX(20px);
}

/* Modal Footer */
.automation-modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    background: linear-gradient(180deg, transparent 0%, rgba(99, 102, 241, 0.05) 100%);
    backdrop-filter: blur(16px);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    border-radius: 0 0 1.5rem 1.5rem;
}

.automation-modal-footer .btn {
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

.automation-modal-footer .btn-secondary,
.automation-modal-footer button:not(.btn-primary) {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

.automation-modal-footer .btn-secondary:hover,
.automation-modal-footer button:not(.btn-primary):hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(148, 163, 184, 0.3);
}

.automation-modal-footer .btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #14b8a6 100%);
    border: none;
    color: white;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.35);
}

.automation-modal-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(99, 102, 241, 0.45);
}

/* Responsive */
@media (max-width: 1024px) {
    .automation-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .automation-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem;
    }

    .automation-card {
        min-height: 200px;
        padding: 1rem;
    }

    .automation-card .card-icon {
        width: 40px;
        height: 40px;
    }

    .automation-card .card-title {
        font-size: 1rem;
    }

    .automation-card .card-tagline {
        font-size: 0.8125rem;
    }

    .automation-modal {
        max-width: 100%;
        max-height: 90vh;
        margin: 0.5rem;
    }

    .automation-modal-header {
        padding: 1rem;
    }

    .automation-modal-body {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .automation-grid {
        padding: 0 0.75rem;
    }

    .automation-card {
        min-height: 180px;
        padding: 0.875rem;
    }
}

/* Animation */
@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.automation-card {
    animation: cardFadeIn 0.4s ease-out backwards;
}

.automation-card:nth-child(1) { animation-delay: 0.05s; }
.automation-card:nth-child(2) { animation-delay: 0.1s; }
.automation-card:nth-child(3) { animation-delay: 0.15s; }
.automation-card:nth-child(4) { animation-delay: 0.2s; }
.automation-card:nth-child(5) { animation-delay: 0.25s; }
.automation-card:nth-child(6) { animation-delay: 0.3s; }
.automation-card:nth-child(7) { animation-delay: 0.35s; }
.automation-card:nth-child(8) { animation-delay: 0.4s; }

/* Success message animation */
@keyframes successPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}
