:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --danger-color: #ef4444;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shine: rgba(255, 255, 255, 0.05);

    --font-main: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    /* Rich gradient background */
    background: radial-gradient(circle at top left, #1e293b, #0f172a);
    overflow-x: hidden;
}

/* Utilities */
.hidden {
    display: none !important;
}

.screen {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-radius: 16px;
}

/* Login Screen */
#login-screen {
    align-items: center;
    justify-content: center;
}

.login-card {
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Forms */
.input-group {
    position: relative;
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.8rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group select {
    padding-left: 1rem;
}

.input-group input:focus {
    border-color: var(--primary-color);
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    transition: all 0.2s;
}

.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
}

.btn-secondary:hover {
    color: var(--text-color);
    border-color: var(--text-muted);
}

.btn-danger {
    padding: 0.75rem 1.5rem;
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}


.error-msg {
    color: var(--danger-color);
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.2rem;
}

/* Dashboard */
header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.logo i {
    color: var(--primary-color);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: 50%;
}

.btn-icon:hover {
    color: var(--text-color);
    background: var(--glass-shine);
}

main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.section-title {
    margin: 2rem 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.service-card {
    text-decoration: none;
    color: var(--text-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: transform 0.2s, background 0.2s, opacity 0.2s;
    position: relative;
    /* Ensure ::after is positioned relative to card */
}

/* Loading Animation for Cards */
.service-card.loading {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
    pointer-events: none;
    /* Prevent double clicks */
}

.service-card.loading .service-icon {
    animation: pulseIcon 0.8s infinite;
}

@keyframes pulseIcon {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(0.8);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading spinner overlay */
.service-card.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin-top: -12px;
    margin-left: -12px;
    /* Center perfectly */
    border-radius: 50%;
    /* Make it round */
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    /* Bright spinner */
    /* Start hidden, fade in after 250ms */
    opacity: 0;
    animation: spin 0.8s linear infinite, fadeInSpinner 0.2s forwards 0.25s;
    z-index: 100;
    display: block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeInSpinner {
    to {
        opacity: 1;
    }
}

.service-card:hover {
    transform: translateY(-4px);
    background: rgba(30, 41, 59, 0.9);
}

.service-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    /* Default icon color */
    margin-bottom: 0.5rem;
}

.service-title {
    font-weight: 500;
    text-align: center;
}

/* Admin/Edit Mode styles */
.edit-mode .service-card {
    border: 1px dashed var(--primary-color);
    cursor: grab;
}

.edit-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.service-card:hover .edit-overlay {
    opacity: 1;
}

.add-card {
    border: 2px dashed var(--glass-border);
    background: transparent;
    cursor: pointer;
    min-height: 160px;
    /* Match approximate height */
    justify-content: center;
}

.add-card:hover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 0.2s;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    padding: 2rem;
}

.modal h2 {
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.spacer {
    flex: 1;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Delete button on card */
.delete-btn-card {
    position: absolute;
    top: -10px;
    right: -10px;
    background: rgba(239, 68, 68, 1);
    color: white;
    border: 2px solid var(--bg-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.delete-btn-card:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.service-card:hover .delete-btn-card {
    opacity: 1;
}