/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --accent-color: #06b6d4;
    --background: #0f0f23;
    --surface: #1a1a2e;
    --surface-light: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border: #27272a;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    background: var(--background);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    scroll-behavior: smooth;
}

/* Background animation */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: 
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 60% 60%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
    animation: backgroundShift 30s ease-in-out infinite;
}

@keyframes backgroundShift {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    25% { 
        transform: scale(1.05) rotate(0.5deg);
        opacity: 0.8;
    }
    50% { 
        transform: scale(1.1) rotate(1deg);
        opacity: 1;
    }
    75% { 
        transform: scale(1.05) rotate(0.5deg);
        opacity: 0.9;
    }
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 3rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out;
    position: relative;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-top: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    min-height: 70px;
    padding: 0.75rem 0;
    overflow: visible;
}

.logo i {
    font-size: 3rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 8px rgba(99, 102, 241, 0.3));
}

.header h1 {
    font-size: 3rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.03em;
    line-height: 1.1;
    filter: drop-shadow(0 4px 8px rgba(99, 102, 241, 0.3));
    transform: translateZ(0);
    will-change: transform;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
    opacity: 0.8;
    letter-spacing: 0.02em;
}

/* Services Grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Service Cards */
.service-card {
    background: rgba(26, 26, 46, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.service-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.service-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

.service-card:hover::before {
    transform: scaleX(1);
}

.service-card:hover::after {
    opacity: 1;
}

.service-card[data-service="photos"]::before { background: var(--gradient-primary); }
.service-card[data-service="portainer"]::before { background: var(--gradient-secondary); }
.service-card[data-service="n8n"]::before { background: var(--gradient-accent); }
.service-card[data-service="homeassistant"]::before { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.service-card[data-service="pihole"]::before { background: linear-gradient(135deg, #00b894, #00a085); }
.service-card[data-service="plex"]::before { background: linear-gradient(135deg, #fdcb6e, #e17055); }
.service-card[data-service="transmission"]::before { background: linear-gradient(135deg, #74b9ff, #0984e3); }

.service-icon {
    width: 70px;
    height: 70px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    background: var(--surface-light);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.service-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.service-card:hover .service-icon {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.service-card:hover .service-icon::before {
    opacity: 1;
}

.service-card[data-service="photos"] .service-icon { background: linear-gradient(135deg, #667eea, #764ba2); }
.service-card[data-service="portainer"] .service-icon { background: linear-gradient(135deg, #f093fb, #f5576c); }
.service-card[data-service="n8n"] .service-icon { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.service-card[data-service="homeassistant"] .service-icon { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.service-card[data-service="pihole"] .service-icon { background: linear-gradient(135deg, #00b894, #00a085); }
.service-card[data-service="plex"] .service-icon { background: linear-gradient(135deg, #fdcb6e, #e17055); }
.service-card[data-service="transmission"] .service-icon { background: linear-gradient(135deg, #74b9ff, #0984e3); }

.service-icon i {
    font-size: 1.5rem;
    color: white;
}

.service-content h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.service-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.5;
    font-weight: 400;
    opacity: 0.8;
}

.service-link {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: scale(0.8) rotate(-10deg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.service-card:hover .service-link {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    background: var(--primary-color);
    color: white;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

.service-link.disabled {
    background: rgba(113, 113, 122, 0.3);
    cursor: not-allowed;
    border-color: rgba(113, 113, 122, 0.2);
}

.service-link.disabled:hover {
    background: rgba(113, 113, 122, 0.3);
    transform: scale(0.8) rotate(-10deg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.footer i {
    color: var(--error);
    animation: heartbeat 2s ease-in-out infinite;
}

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

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem;
        padding-top: 2.5rem;
    }
    
    .header h1 {
        font-size: 2.5rem;
    }
    
    .logo i {
        font-size: 2.5rem;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .service-card {
        padding: 1.5rem;
    }
    
    .service-icon {
        width: 60px;
        height: 60px;
    }
    
    .search-input {
        padding: 0.875rem 0.875rem 0.875rem 2.5rem;
        font-size: 0.95rem;
    }
    
    .search-icon {
        font-size: 1rem;
    }
    
    .logo {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .status-indicator {
        width: 10px;
        height: 10px;
        top: 1.25rem;
        left: 1.25rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
        padding-top: 1.5rem;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .logo i {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .service-card {
        padding: 1.25rem;
    }
    
    .service-icon {
        width: 50px;
        height: 50px;
        margin-bottom: 1rem;
    }
    
    .service-icon i {
        font-size: 1.25rem;
    }
    
    .service-content h3 {
        font-size: 1.2rem;
    }
    
    .service-content p {
        font-size: 0.9rem;
    }
    
    .search-input {
        padding: 0.75rem 0.75rem 0.75rem 2.25rem;
        font-size: 0.9rem;
        border-radius: 12px;
    }
    
    .search-icon {
        font-size: 0.9rem;
        left: 0.75rem;
    }
    
    .service-link {
        width: 40px;
        height: 40px;
        top: 1.25rem;
        right: 1.25rem;
    }
    
    .status-indicator {
        width: 8px;
        height: 8px;
        top: 1rem;
        left: 1rem;
    }
}

/* Loading animation for cards */
.service-card {
    animation: cardAppear 0.8s ease-out both;
    animation-delay: calc(var(--card-index, 0) * 0.1s);
}

.service-card:nth-child(1) { --card-index: 1; }
.service-card:nth-child(2) { --card-index: 2; }
.service-card:nth-child(3) { --card-index: 3; }
.service-card:nth-child(4) { --card-index: 4; }
.service-card:nth-child(5) { --card-index: 5; }
.service-card:nth-child(6) { --card-index: 6; }
.service-card:nth-child(7) { --card-index: 7; }

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

/* Hover animations */
.service-card:hover .service-content h3 {
    transform: translateX(5px);
    transition: transform 0.3s ease;
}

.service-card:hover .service-content p {
    transform: translateX(5px);
    transition: transform 0.3s ease 0.1s;
}

/* Loading skeleton animation */
@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.1) 25%, 
        rgba(255, 255, 255, 0.2) 50%, 
        rgba(255, 255, 255, 0.1) 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
}

/* Focus states for accessibility */
.service-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.service-card:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Light theme support */
.light-theme {
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-light: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

.light-theme .background-animation {
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.1) 0%, transparent 50%);
}

.light-theme .service-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.light-theme .service-card:hover {
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.15);
    transform: translateY(-12px) scale(1.02);
}

.light-theme .service-card::after {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.05) 0%, transparent 50%);
}

.light-theme .service-content h3 {
    color: var(--text-primary);
}

.light-theme .service-content p {
    color: var(--text-secondary);
}

.light-theme .search-input {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.light-theme .search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.15),
        0 0 0 3px rgba(99, 102, 241, 0.1);
}

.light-theme .service-link {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
}

.light-theme .service-card:hover .service-link {
    background: var(--primary-color);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.light-theme .theme-toggle {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.light-theme .theme-toggle:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.light-theme .service-icon {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.light-theme .service-card:hover .service-icon {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.light-theme .service-link.disabled {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
}

.light-theme .service-link.disabled:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(0.8) rotate(-10deg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0a0a0a;
        --surface: #1a1a1a;
        --surface-light: #2a2a2a;
    }
}

/* Search Container */
.search-container {
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.1s both;
}

.search-wrapper {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: color 0.3s ease;
    z-index: 1;
}

.search-input:focus + .search-icon {
    color: var(--primary-color);
}

.search-results-count {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-results-count.show {
    opacity: 1;
}

/* Status indicators */
.status-indicator {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 15px var(--success);
    animation: pulse 2s infinite;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.status-indicator.offline {
    background: var(--error);
    box-shadow: 0 0 15px var(--error);
}

.status-indicator.warning {
    background: var(--warning);
    box-shadow: 0 0 15px var(--warning);
}

.status-indicator.loading {
    background: var(--text-secondary);
    box-shadow: 0 0 15px var(--text-secondary);
    animation: spin 1s linear infinite;
}

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

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
