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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 16px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-primary {
    background-color: #007AFF;
    color: white;
}

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

.btn-secondary {
    background-color: #f5f5f7;
    color: #007AFF;
    border: 1px solid #d2d2d7;
}

.btn-secondary:hover {
    background-color: #e0e0e0;
}

.btn-full {
    width: 100%;
    padding: 12px;
}

.btn-icon {
    background: none;
    color: #007AFF;
    padding: 8px 12px;
    border-radius: 8px;
}

.btn-icon:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

/* Loading screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 122, 255, 0.2);
    border-top: 4px solid #007AFF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

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

/* Main app layout */
.main-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background-color: white;
    border-bottom: 1px solid #d2d2d7;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    z-index: 1001;
}

.menu-btn:hover {
    background-color: #f5f5f7;
}

.menu-btn span {
    width: 20px;
    height: 2px;
    background-color: #1d1d1f;
    border-radius: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background-color: white;
    border-right: 1px solid #d2d2d7;
    overflow-y: auto;
    transition: transform 0.3s ease, margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
    flex-shrink: 0; 
}

.sidebar-content {
    padding: 24px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.nav-section {
    margin-bottom: 32px;
}

.nav-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    padding: 0 8px;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-radius: 12px;
    text-decoration: none;
    color: #1d1d1f;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: #f5f5f7;
}

.nav-link.active {
    background-color: #e6f0ff;
    color: #007AFF;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.calendar-list {
    list-style: none;
}

.calendar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-item:hover {
    background-color: #f5f5f7;
}

.calendar-item.active {
    background-color: #e6f0ff;
}

.calendar-color {
    width: 16px;
    height: 16px;
    border-radius: 8px;
}

.nav-section-bottom {
    margin-top: auto;
    margin-bottom: 0;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.view-header h2 {
    font-size: 24px;
    font-weight: 700;
}

/* Calendar view styles */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #d2d2d7;
}

.date-navigation h2 {
    font-size: 24px;
    font-weight: 700;
}

.view-options {
    display: flex;
    gap: 8px;
}

.view-btn {
    padding: 8px 16px;
    border-radius: 8px;
    background-color: #f5f5f7;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.view-btn.active {
    background-color: #007AFF;
    color: white;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: #d2d2d7;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    overflow: hidden;
}

/* Appointments view styles */
.appointments-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.appointment-item {
    display: flex;
    padding: 16px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.appointment-time {
    width: 80px;
    font-weight: 600;
    color: #007AFF;
}

.appointment-details {
    flex: 1;
}

.appointment-details h3 {
    margin-bottom: 4px;
    font-size: 18px;
}

.appointment-details p {
    color: #86868b;
    margin-bottom: 8px;
}

.appointment-meta {
    display: flex;
    gap: 16px;
}

.meta-item {
    font-size: 14px;
    color: #86868b;
}

.meta-item.type-tag {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: capitalize;
}

.meta-item.type-appointment {
    background-color: #e6f0ff; /* Light blue */
    color: #007AFF; /* Darker blue */
}

.meta-item.type-event {
    background-color: #ffe6e6; /* Light red */
    color: #FF3B30; /* Darker red */
}

/* Availability view styles */
.availability-settings {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.availability-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.availability-day {
    padding: 16px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
}

.availability-day h4 {
    margin-bottom: 8px;
    font-size: 16px;
}

.time-slot {
    font-size: 14px;
    color: #86868b;
}

/* Profile view styles */
.profile-form {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    max-width: 500px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input[type="checkbox"] {
    width: auto; /* Override width: 100% for checkboxes */
    margin-right: 8px; /* Space between checkbox and label */
    padding: initial; /* Reset padding */
    border: initial; /* Reset border */
    border-radius: initial; /* Reset border-radius */
    vertical-align: middle; /* Align checkbox vertically with text */
}

.form-group input[type="checkbox"] + label {
    display: inline-block; /* Make label inline with checkbox */
    margin-bottom: 0; /* Remove bottom margin */
}

/* Hide the actual checkbox */
.hidden-checkbox {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Style the label to look like a button */
.checkbox-button {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background-color: #f5f5f7;
    color: #1d1d1f;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    text-align: center;
    min-width: 120px; /* Ensure a consistent button width */
}

/* Style for when the checkbox is checked */
.hidden-checkbox:checked + .checkbox-button {
    background-color: #007AFF;
    color: white;
    border-color: #007AFF;
}

/* Hover state for the button */
.checkbox-button:hover {
    background-color: #e0e0e0;
    border-color: #c0c0c0;
}

/* Adjust form-group for checkbox-button-group to allow multiple buttons on one line */
.form-group.checkbox-button-group {
    display: inline-block; /* Allow buttons to sit next to each other */
    margin-right: 10px; /* Space between buttons */
    /* Keep original form-group margin-bottom if needed, or adjust here */
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 16px;
}

.form-group input[readonly] {
    background-color: #f5f5f7;
}

/* Settings view styles */
.settings-section {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.settings-section h3 {
    margin-bottom: 16px;
    font-size: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f5f5f7;
}

.setting-item:last-child {
    border-bottom: none;
}

/* Integrations view styles */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
}

.integration-card {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.integration-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #007AFF;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    margin: 0 auto 16px;
}

.integration-card h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.integration-card p {
    color: #86868b;
    margin-bottom: 16px;
}

/* Week view styles */
.week-view {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background-color: #f5f5f7;
    border-bottom: 1px solid #d2d2d7;
}

.day-header {
    padding: 16px;
    text-align: center;
    font-weight: 600;
    border-right: 1px solid #d2d2d7;
}

.day-header:last-child {
    border-right: none;
}

/* Day view styles */
.day-view {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 24px;
}

.day-header h3 {
    margin-bottom: 16px;
    font-size: 20px;
    text-align: center;
}

/* Responsive design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 999;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .app-header {
        padding: 16px;
    }
    
    .header-right {
        gap: 8px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .calendar-grid {
        grid-template-columns: repeat(1, 1fr);
    }
    
    .appointment-item {
        flex-direction: column;
    }
    
    .appointment-time {
        width: auto;
        margin-bottom: 8px;
    }
}

/* Desktop sidebar behavior */
@media (min-width: 769px) {
    .sidebar {
        position: relative;
        transform: translateX(0);
    }

    .sidebar:not(.open) {
        margin-left: -280px;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 24px;
    border: 1px solid #d2d2d7;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    max-height: 90vh; /* Added to limit height to 90% of viewport height */
    overflow-y: auto; /* Added to enable vertical scrolling */
    overflow-x: hidden; /* Added to prevent horizontal scrolling */
}

.close-btn {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover,
.close-btn:focus {
    color: #333;
}

/* Styles for Add Calendar Button */
.nav-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    margin-bottom: 16px;
}

.nav-section-header h3 {
    margin-bottom: 0;
}

.btn-icon-sm {
    background: none;
    border: none;
    font-size: 20px;
    font-weight: bold;
    color: #007AFF;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
}

.btn-icon-sm:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

/* Custom Calendar Selector */
.calendar-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.calendar-selector .radio-option {
    display: inline-block;
    position: relative;
}

.calendar-selector .radio-option input[type="radio"] {
    opacity: 0;
    position: fixed;
    width: 0;
}

.calendar-selector .radio-option label {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-size: 14px;
}

.calendar-selector .radio-option input[type="radio"]:checked + label {
    background-color: #e0e0e0;
    border-color: #007AFF;
    font-weight: 600;
}

.calendar-selector .radio-option .color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Event Popover */
.event-popover {
    position: absolute;
    z-index: 1002;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 16px;
    width: 280px;
    font-size: 14px;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s ease-in-out, transform 0.15s ease-in-out;
    pointer-events: none; /* Initially not interactive */
}

.event-popover.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto; /* Interactive when visible */
}

.event-popover h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.event-popover p {
    margin-bottom: 4px;
    color: #555;
}

.event-popover .popover-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

/* Arrow pointing up */
.event-popover.arrow-down .popover-arrow {
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0 8px;
    border-color: white transparent transparent transparent;
}

/* Arrow pointing down */
.event-popover.arrow-up .popover-arrow {
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 8px 8px 8px;
    border-color: transparent transparent white transparent;
}
/* Recurrence Options Styling */
.recurrence-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* Space between buttons */
}

/* Pending Appointments View Styles */
.pending-appointments-view {
    padding: 24px; /* Consistent with other views */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.pending-appointments-header {
    margin-bottom: 24px;
}

.pending-appointments-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1d1d1f;
}

.pending-appointments-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pending-item {
    display: flex;
    flex-direction: column; /* Stack details and actions vertically */
    padding: 16px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pending-item .appointment-details {
    padding-left: 0; /* Remove left padding from base appointment-details */
    border-left: none; /* Remove border from base appointment-details */
    margin-bottom: 16px; /* Space between details and actions */
}

.pending-item .appointment-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end; /* Align buttons to the right */
    margin-top: auto; /* Push actions to the bottom if content varies */
}

.pending-item .appointment-actions .btn {
    flex: 1; /* Make buttons take equal width */
}

/* Specific styles for no appointments and error messages within pending view */
.pending-appointments-view .no-appointments,
.pending-appointments-view .error-message,
.pending-appointments-view .loading-message {
    text-align: center;
    padding: 20px;
    color: #86868b;
    font-size: 16px;
}

.pending-appointments-view .error-message {
    color: #FF3B30;
}