:root {
    --primary-color: #1a73e8;
    --primary-hover: #1557b0;
    --text-dark: #202124;
    --text-light: #5f6368;
    --bg-light: #f8f9fa;
    --white: #fff;
    --border-color: #dadce0;
    --success-color: #1e8e3e;
    --danger-color: #d93025;
    --shadow-sm: 0 1px 2px 0 rgb(60 64 67 / 30%), 0 1px 3px 1px rgb(60 64 67 / 15%);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 10%), 0 2px 4px -1px rgb(0 0 0 / 6%);
    --font-stack: 'Inter', -apple-system, blinkmacsystemfont, "Segoe UI", roboto, helvetica, arial, sans-serif;

    /* Spacing Scale */
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-5: 1.25rem;
    --spacing-6: 1.5rem;
    --spacing-8: 2rem;
    --spacing-10: 2.5rem;
    --spacing-12: 3rem;

    /* Extended Colors */
    --badge-bg: #e8f0fe;
    --badge-text: #1967d2;
}

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

body {
    font-family: var(--font-stack);
    margin: 0;
    padding: 0;
    color: var(--text-dark);
    background-color: var(--bg-light);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    padding: 1rem 5%;
    background: rgb(255 255 255 / 95%);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgb(0 0 0 / 5%);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-dark);
}

.logo-img {
    height: 32px;
    width: auto;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Hero Section */
.hero-section {
    padding: 6rem 5% 4rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    width: 90%;
}

.hero-content {
    max-width: 600px;
}

.hero-headline {
    font-size: 3.5rem;
    line-height: 1.1;
    font-weight: 800;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #1a73e8 0%, #a50eef 100%);
    /* stylelint-disable-next-line property-no-vendor-prefix */
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subheadline {
    font-size: 1.25rem;
    color: var(--text-light);
    margin-bottom: 2.5rem;
}

.hero-image-container {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgb(0 0 0 / 20%);
}

.hero-image {
    width: 100%;
    height: auto;
    display: block;
    transform: scale(1.02);
    transition: transform 0.5s ease;
}

.hero-image:hover {
    transform: scale(1.05);
}

/* Features Section */
.features-section {
    padding: 4rem 5%;
    background-color: var(--white);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.feature-card {
    background: var(--bg-light);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.feature-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-description {
    color: var(--text-light);
}

/* Footer */
footer {
    margin-top: auto;
    padding: 2rem 5%;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--white);
}

/* Dashboard Styles */
.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout-form {
    display: inline;
}

.dashboard-container {
    padding: 2rem 5%;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 1px 3px rgb(0 0 0 / 10%);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline:hover {
    background-color: rgb(26 115 232 / 5%);
}

.btn-secondary {
    background-color: white;
    color: var(--text-dark);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-light);
    border-color: #ccc;
}

.btn-danger {
    background-color: white;
    color: var(--danger-color);
    border-color: var(--border-color);
    padding: 0.5rem 0.8rem;
}

.btn-danger:hover {
    background-color: #fce8e6;
    border-color: #f5c6cb;
}

.btn-outline-danger {
    background-color: transparent;
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-outline-danger:hover {
    background-color: #fce8e6;
    border-color: var(--danger-color);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.btn-copy-success {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.btn-copy-success:hover {
    background-color: #137333; /* Darker green */
    border-color: #137333;
}

.btn-copy-icon {
    margin-left: 0.5rem;
    vertical-align: middle;
    font-weight: normal;
}

/* Form & Card Styles */
.form-card {
    background: var(--white);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 900px;
    margin: 2rem auto;
    border: 1px solid var(--border-color);
}

.form-header-group {
    margin-bottom: 2rem;
    text-align: center;
}

.form-card h1 {
    font-size: 1.75rem;
    margin: 0 0 0.5rem;
    color: var(--text-dark);
}

.form-group {
    margin-bottom: 2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-dark);
}

input[type="text"],
input[type="url"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--white);
}

input[type="text"]:focus,
input[type="url"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(26 115 232 / 10%);
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Help Box (Collapsible) */
details.help-box {
    background-color: transparent;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
    border: 1px solid transparent;
    border-radius: 8px;
    transition: all 0.2s;
}

details.help-box[open] {
    background-color: #f8f9fa;
    border-color: var(--border-color);
    padding: 1rem;
}

summary.help-summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--primary-color);
    list-style: none;

    /* Hide default triangle */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
}

summary.help-summary::-webkit-details-marker {
    display: none;
}

summary.help-summary::before {
    content: '▶';
    font-size: 0.7em;
    transition: transform 0.2s;
}

details[open] summary.help-summary::before {
    transform: rotate(90deg);
}

.help-content {
    margin-top: 0.75rem;
    color: var(--text-dark);
    line-height: 1.5;
}

.info-box {
    /* Keep for legacy or specialized uses if any, otherwise can eventually remove */
    background: #e8f0fe;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: #174ea6;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.info-box-icon {
    font-size: 1.2rem;
}

/* Source Entry Grid */
.source-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ical-entry {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    display: grid;
    grid-template-columns: minmax(140px, auto) 1fr minmax(140px, auto) auto;
    gap: 1rem;
    align-items: start;
    transition: border-color 0.2s, opacity 0.2s ease-out, transform 0.2s ease-out;
    position: relative;
}

.ical-entry:hover {
    border-color: #ccc;
}

.ical-entry.adding {
    animation: fade-in 0.3s ease-out;
}

.ical-entry.removing {
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .ical-entry {
        transition: none;
        animation: none;
    }

    .ical-entry.adding {
        animation: none;
    }

    .ical-entry.removing {
        opacity: 0;
        transform: none;
    }
}

/* Source Type Select (First Column) */
.source-type-group {
    display: flex;
    flex-direction: column;
}

.field-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* Input Fields (Second Column) */
.source-input-group {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.source-input-group .input-row {
    width: 100%;
}

/* Prefix (Third Column) */
.source-prefix-group {
    display: flex;
    flex-direction: column;
}

/* Actions (Fourth Column) */
.source-actions {
    display: flex;
    align-items: center;
    height: 100%;

    /* Align with inputs handled by hidden label in HTML */
    padding-top: 0;
}

/* Add Button */
.add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 2px dashed var(--border-color);
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
    width: 100%;
    border-radius: 8px;
    justify-content: center;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.add-btn:hover {
    border-color: var(--primary-color);
    background-color: rgb(26 115 232 / 5%);
    text-decoration: none;
}

/* Action Buttons Footer */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Responsive */
@media (width <=900px) {
    .ical-entry {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1.25rem;
    }

    .source-actions {
        padding-top: 0;
        justify-content: flex-end;
    }

    .form-card {
        padding: 1.5rem;
    }
}

/* Dashboard & Sync Card Redesign */
.dashboard-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fade-in 0.5s ease-out;
}

.dashboard-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.dashboard-header p {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.sync-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.sync-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.sync-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #ccc;
}

.sync-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.sync-destination {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: break-word;
    flex-grow: 1;

    /* Allow it to take up space */
}

.sync-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
    width: 110px;

    /* Fixed width for consistency */
}

.sync-actions form {
    width: 100%;

    /* Ensure form fills the container */
    display: flex;
    margin: 0;
}

.sync-actions .btn {
    width: 100%;
    padding: 0.4rem 0.5rem;

    /* Reduced padding to fit text */
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;

    /* Critical for padding/width calc */
    text-align: center;
}

.sync-body {
    flex-grow: 1;
}

.sync-source-label {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);

    /* Lighter label */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sync-source-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    /* More breathing room */
}

.sync-source-item {
    font-size: 0.95rem;
    color: var(--text-dark);
    display: grid;

    /* Use grid for strict alignment */
    grid-template-columns: 70px 1fr;

    /* Badge Col | Text Col */
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

/* Helper for items without badges to align text correctly */
.sync-source-item.no-badge {
    grid-template-columns: 1fr;
}

.source-badge {
    background: var(--badge-bg);
    color: var(--badge-text);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    width: 100%;

    /* Fill the grid column */
    box-sizing: border-box;
}

/* Ensure text truncates nicely */
.sync-source-item>span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


.sync-footer {
    margin-top: var(--spacing-8);
    padding-top: var(--spacing-4);
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 4rem 2rem;
    background: var(--bg-light);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

.empty-state-text {
    font-size: 1.2rem;
    margin-bottom: var(--spacing-4);
}

.dashboard-cta {
    font-size: 1.05rem;
    padding: 0.7rem 1.5rem;
}


/* Danger Zone */
.form-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

.danger-zone {
    border: 1px solid #f5c6cb;
    background-color: #fff8f8;
    padding: 1.5rem;
    border-radius: 8px;
    color: #721c24;
}

.danger-zone h3 {
    margin-top: 0;
    font-size: 1.25rem;
    color: var(--danger-color);
    margin-bottom: 0.5rem;
}

.danger-zone p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.help-paragraph {
    margin: 0 0 0.5rem;
}

.help-list {
    padding-left: 1.2rem;
    margin: 0;
}

/* Linting cleanup classes */
.refresh-link {
    color: var(--primary-color);
}

.visibility-hidden {
    visibility: hidden;
}

.display-none {
    display: none;
}

.btn-loading {
    opacity: 0.8;
    pointer-events: none;
    cursor: not-allowed;
}

/* Flash Messages */
.flash-messages-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 5% 0;
    box-sizing: border-box;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: fade-in 0.3s ease-out;
    transition: opacity 0.5s ease-out;
}

.fade-out {
    opacity: 0;
}

.alert-success {
    background-color: #e6f4ea;
    color: var(--success-color);
    border: 1px solid #b7e1cd;
}

.alert-danger {
    background-color: #fce8e6;
    color: var(--danger-color);
    border: 1px solid #f5c6cb;
}

.alert-info {
    background-color: var(--badge-bg);
    color: var(--badge-text);
    border: 1px solid #c2d7fa;
}

/* Close button for alerts (optional but good UX) */
.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentcolor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin-right: 0.5rem;
    vertical-align: text-bottom;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}
