﻿:root {
    --primary-color: #005aa3; /* Swedish Blueish */
    --secondary-color: #fecb00; /* Swedish Yellowish */
    --text-color: #333;
    --background-color: #f4f7fa;
    --card-background: #ffffff;
    --border-radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --spacing-unit: 1rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

header {
    background-color: var(--card-background);
    padding: var(--spacing-unit) 2rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
}

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

.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #666;
}

input, select {
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 90, 163, 0.1);
}

/* Search input specific styling */
.search-input {
    background: white;
    position: relative;
}

.search-input::placeholder {
    color: #a0aec0;
    font-style: italic;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 90, 163, 0.15);
}

/* Native search input clear button styling (WebKit browsers) */
.search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    height: 1.25rem;
    width: 1.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a0aec0'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
    background-size: 1.25rem 1.25rem;
    cursor: pointer;
}

.search-input::-webkit-search-cancel-button:hover {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23005aa3'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: #004480;
    transform: translateY(-1px);
}

.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* When table view replaces event-grid, this ensures table takes full width */
#event-list.event-table-container {
    display: block;
}

#event-list:has(.event-table-container) {
    display: block;
}

.event-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: pointer;
    user-select: none;
    transform-style: preserve-3d;
}

/* Added state - keep the visual styling */
.event-card.added {
    background: linear-gradient(135deg, #e6f3ff 0%, #f0f7ff 100%);
    border: 2px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 90, 163, 0.15);
}

.event-card.added .event-title {
    color: var(--primary-color);
}

.event-card.flipping {
    transform: rotateY(180deg);
}

/* Ensure smooth flip */
.event-card .event-content,
.event-card .status-indicator {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Back face of card (when flipping) */
.event-card::before {
    content: attr(data-flip-message);
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, #004480 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    transform: rotateY(180deg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.event-card.flipping::before {
    opacity: 1;
}

/* Scale effect on hover for better interaction feedback */
.event-card:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 90, 163, 0.2);
}

.event-card.added:hover {
    box-shadow: 0 8px 16px rgba(0, 90, 163, 0.3);
}

.event-card.flipping:hover {
    transform: rotateY(180deg) scale(1.02);
}

/* Status indicator - always visible for added events */
.status-indicator {
    position: absolute;
    top: -10px;
    right: 15px;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0, 90, 163, 0.3);
    z-index: 10;
    animation: statusSlideIn 0.3s ease-out;
    transition: all 0.3s ease;
}

@keyframes statusSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.status-indicator-add {
    background: #e2e8f0;
    color: #4a5568;
}

.event-card:hover .status-indicator-add {
    background: var(--primary-color);
    color: white;
}

.event-content {
    flex-grow: 1;
    padding-top: 0.5rem;
}

.event-date {
    font-size: 0.875rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

.event-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #1a202c;
}

.event-details {
    color: #718096;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.event-location {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.calendar-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.calendar-info {
    background: #e6ffFA;
    border: 1px solid #38b2ac;
    color: #234e52;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.calendar-info h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.calendar-info ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.calendar-info li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: #234e52;
}

.calendar-info li:before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.calendar-info li:last-child {
    margin-bottom: 0;
}

.no-results {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    color: #718096;
    font-size: 1.1rem;
}

.event-deadline {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.deadline-normal {
    background: #e6ffed;
    color: #22543d;
    border-left: 3px solid #38a169;
}

.deadline-soon {
    background: #fef5e7;
    color: #744210;
    border-left: 3px solid #ed8936;
}

.deadline-urgent {
    background: #fff5f5;
    color: #742a2a;
    border-left: 3px solid #f56565;
    animation: pulse-deadline 2s ease-in-out infinite;
}

@keyframes pulse-deadline {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.hidden {
    display: none;
}

/* Toggle Switch */
.toggle-checkbox {
    display: none;
}

.toggle-label {
    width: 50px;
    height: 26px;
    background: #ccc;
    border-radius: 50px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

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

.toggle-checkbox:checked + .toggle-label {
    background: var(--primary-color);
}

.toggle-checkbox:checked + .toggle-label::after {
    transform: translateX(24px);
}

/* District Pills */
.district-group {
    min-width: 300px;
}

.district-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.district-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0.5rem;
   // border: 1px solid #e2e8f0;
   // border-radius: 6px;
   // background: #f7fafc;
    align-items: center;
}

.district-placeholder {
    color: #a0aec0;
    font-size: 0.875rem;
    font-style: italic;
}

.district-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #004480 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 90, 163, 0.2);
    transition: all 0.2s;
    animation: pillSlideIn 0.2s ease-out;
}

.district-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 90, 163, 0.3);
}

.pill-remove {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    transition: all 0.2s;
    font-weight: bold;
}

.pill-remove:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.pill-remove:active {
    transform: scale(0.95);
}

@keyframes pillSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .district-group {
        min-width: 100%;
    }
    
    .district-pills {
        min-height: 3rem;
    }
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 0;
    background: #e2e8f0;
    padding: 0.25rem;
    border-radius: 8px;
    align-items: center;
    width: fit-content;
}

.view-toggle-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: #4a5568;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.view-toggle-btn:hover {
    background: rgba(0, 90, 163, 0.1);
    color: var(--primary-color);
}

.view-toggle-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 90, 163, 0.3);
}

/* Table View Styles */
.event-table-container {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.event-table {
    width: 100%;
    border-collapse: collapse;
}

.event-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, #004480 100%);
    color: white;
}

.event-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Compact column widths */
.event-table .col-status {
    width: 40px;
    text-align: center;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.event-table .col-date {
    width: 110px;
    white-space: nowrap;
}

.event-table .col-district {
    width: 120px;
}

.event-table .col-type {
    width: 150px;
}

.event-table .col-deadline {
    width: 120px;
    white-space: nowrap;
}

.event-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.event-table tbody tr:hover {
    background: #f7fafc;
    transform: translateX(4px);
    box-shadow: -4px 0 0 0 var(--primary-color);
}

.event-table tbody tr.added {
    background: linear-gradient(135deg, #e6f3ff 0%, #f0f7ff 100%);
    border-left: 4px solid var(--primary-color);
}

.event-table tbody tr.added .col-status {
    color: var(--primary-color);
    font-weight: bold;
}

.event-table tbody tr.added:hover {
    background: linear-gradient(135deg, #d9edff 0%, #e6f3ff 100%);
}

/* Smooth toggle animation for table rows */
.event-table tbody tr.flipping {
    animation: smoothToggle 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1;
}

@keyframes smoothToggle {
    0% { 
        transform: scale(1);
        opacity: 1;
    }
    30% {
        transform: scale(0.95);
        opacity: 0.7;
    }
    60% { 
        transform: scale(1.03);
        box-shadow: 0 8px 24px rgba(0, 90, 163, 0.3);
    }
    100% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* Success pulse for added state */
@keyframes successPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 90, 163, 0.5);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(0, 90, 163, 0);
    }
}

.event-table tbody tr.flipping.added {
    animation: smoothToggle 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Smooth status icon transition */
.event-table .col-status {
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.event-table tbody tr.flipping .col-status {
    animation: iconBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes iconBounce {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(0.7) rotate(-15deg);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.5) rotate(15deg);
        opacity: 1;
    }
    75% {
        transform: scale(0.9) rotate(-5deg);
    }
}

.event-table td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    vertical-align: top;
}

.event-table-name {
    font-weight: 600;
    color: var(--text-color);
}

.event-table tbody tr.added .event-table-name {
    color: var(--primary-color);
}

.event-table-date {
    color: #718096;
    white-space: nowrap;
}

/* Date formatting - end date below start date */
.date-end {
    font-size: 0.85rem;
    color: #a0aec0;
    margin-top: 0.25rem;
}

/* Deadline formatting */
.deadline-date {
    color: var(--text-color);
    font-weight: 500;
}

.deadline-warning {
    font-size: 0.75rem;
    color: #ed8936;
    margin-top: 0.25rem;
    font-weight: 600;
}

.event-table-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.event-table-badge-added {
    background: var(--primary-color);
    color: white;
}

.event-table-badge-deadline {
    background: #fef5e7;
    color: #744210;
    border: 1px solid #ed8936;
}

.event-table-badge-deadline-urgent {
    background: #fff5f5;
    color: #742a2a;
    border: 1px solid #f56565;
    animation: pulse 2s ease-in-out infinite;
}

.event-table-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.hidden-view {
    display: none !important;
}

/* Responsive Table */
@media (max-width: 1024px) {
    .event-table {
        font-size: 0.85rem;
    }
    
    .event-table th,
    .event-table td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 768px) {
    .event-table-container {
        overflow-x: auto;
    }
    
    .event-table {
        min-width: 800px;
    }
}

/* Month Divider */
.month-divider {
    background: linear-gradient(135deg, var(--primary-color) 0%, #004480 100%);
    cursor: default !important;
}

.month-divider:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, #004480 100%) !important;
    transform: none !important;
}

.month-divider td {
    padding: 0.5rem 1rem;
    border-top: none;
    border-bottom: 1px solid #cbd5e0;
}

.month-divider-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.month-divider-content::before,
.month-divider-content::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.month-divider-text {
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
    text-transform: uppercase;
    white-space: nowrap;
    letter-spacing: 1px;
}
