/* Reminder Calendar — Light modern SaaS theme */

:root {
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #DBEAFE;
    --white: #FFFFFF;
    --border: #E5E7EB;
    --text: #1F2937;
    --text-muted: #6B7280;
    --success: #059669;
    --success-light: #D1FAE5;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #F9FAFB;
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.app-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    margin: 0 -16px 24px;
    padding: 0 16px;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.brand-icon svg {
    width: 22px;
    height: 22px;
}

.header-brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.app-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform 0.1s;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.25;
}

.btn:active {
    transform: scale(0.98);
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background: var(--white);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #F3F4F6;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
}

.btn-icon {
    padding: 8px;
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-icon:hover {
    background: #F3F4F6;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    padding: 4px 0;
    font-size: 0.875rem;
    cursor: pointer;
    font-family: inherit;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-danger {
    background: var(--white);
    color: var(--danger);
    border-color: var(--border);
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-danger:hover {
    background: var(--danger-light);
    border-color: var(--danger);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Upcoming Section */
.upcoming-section,
.calendar-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.timezone-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: 999px;
}

.reminders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reminders-visible,
.reminders-extra-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reminders-extra-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s ease;
}

.reminders-extra-wrap.is-expanded {
    grid-template-rows: 1fr;
}

.reminders-extra-inner {
    overflow: hidden;
    min-height: 0;
}

.reminders-toggle-wrap {
    display: flex;
    justify-content: center;
    padding-top: 4px;
}

.reminders-toggle-btn {
    background: var(--white);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.reminders-toggle-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-hover);
    color: var(--primary-hover);
}

.reminders-toggle-btn .toggle-icon {
    font-size: 0.75rem;
    line-height: 1;
}

.reminder-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow var(--transition);
}

.reminder-card:hover {
    box-shadow: var(--shadow-sm);
}

.reminder-card.sent-card {
    opacity: 0.85;
    background: #FAFAFA;
}

.reminder-date-block {
    text-align: center;
    min-width: 56px;
    padding: 8px;
    background: var(--primary-light);
    border-radius: var(--radius);
}

.reminder-date-block .day {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.reminder-date-block .month {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary);
    text-transform: uppercase;
}

.reminder-content {
    min-width: 0;
}

.reminder-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.reminder-time {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.reminder-note {
    font-size: 0.9375rem;
    color: var(--text);
    margin-bottom: 6px;
    word-break: break-word;
}

.reminder-recipients {
    font-size: 0.8125rem;
    color: var(--text-muted);
    word-break: break-all;
}

.reminder-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 999px;
}

.badge-pending {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-sent {
    background: var(--success-light);
    color: var(--success);
}

.empty-state,
.loading-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.sent-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 16px 0 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Calendar */
.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.calendar-month-label {
    font-size: 1.25rem;
    font-weight: 600;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calendar-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #F9FAFB;
    border-bottom: 1px solid var(--border);
}

.weekday {
    padding: 10px 4px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day {
    min-height: 90px;
    padding: 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
    background: var(--white);
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-day:hover {
    background: #F9FAFB;
}

.calendar-day.other-month {
    background: #FAFAFA;
}

.calendar-day.other-month .day-number {
    color: var(--text-muted);
    opacity: 0.5;
}

.calendar-day.today {
    background: var(--primary-light);
}

.calendar-day.today .day-number {
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.day-number {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.day-indicators {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.reminder-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
}

.reminder-count {
    font-size: 0.6875rem;
    font-weight: 600;
    background: var(--primary);
    color: var(--white);
    border-radius: 999px;
    padding: 1px 6px;
    line-height: 1.4;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(16px) scale(0.98);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 24px 20px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 16px;
}

/* Form */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.required {
    color: var(--danger);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

textarea,
input[type="date"],
input[type="time"],
input[type="email"],
select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

select[multiple] {
    min-height: 120px;
}

select[multiple] option {
    padding: 6px 8px;
}

select[multiple] option:checked {
    background: var(--primary);
    color: var(--white);
}

.field-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.field-error {
    display: block;
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
    min-height: 0;
}

.field-error:not(:empty) {
    min-height: 1em;
}

input.invalid,
textarea.invalid,
select.invalid,
.email-dual-list.invalid {
    border-color: var(--danger);
}

/* Dual-list email selector */
.email-dual-list {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    background: #FAFAFA;
}

.email-dual-list.invalid {
    box-shadow: 0 0 0 1px var(--danger);
}

.email-list-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.email-list-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.email-list-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding-top: 24px;
}

.email-list-arrow svg {
    width: 20px;
    height: 20px;
}

.email-available-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 140px;
    max-height: 180px;
    overflow-y: auto;
}

.email-available-item {
    padding: 10px 12px;
    font-size: 0.8125rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    word-break: break-all;
}

.email-available-item:last-child {
    border-bottom: none;
}

.email-available-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.email-available-item::after {
    content: ' →';
    float: right;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.email-available-item:hover::after {
    color: var(--primary);
}

.email-available-empty {
    padding: 16px 12px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
}

.email-selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 140px;
    max-height: 180px;
    overflow-y: auto;
    padding: 10px;
}

.email-selected-empty {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 4px;
}

.email-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 5px 8px 5px 10px;
    border-radius: 999px;
    max-width: 100%;
    line-height: 1.3;
    cursor: pointer;
}

.email-tag-text {
    word-break: break-all;
}

.email-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    background: rgba(255, 255, 255, 0.25);
    color: var(--white);
    border-radius: 50%;
    font-size: 0.875rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition);
}

.email-tag-remove:hover {
    background: rgba(255, 255, 255, 0.4);
}

.custom-emails-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.custom-email-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.custom-email-row input {
    flex: 1;
}

.custom-email-row .btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 6px;
    font-size: 1.25rem;
    line-height: 1;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text);
    color: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(80px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 2000;
    max-width: 360px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .header-brand {
        justify-content: center;
    }

    #addReminderBtn {
        width: 100%;
        justify-content: center;
    }

    .reminder-card {
        grid-template-columns: auto 1fr;
    }

    .reminder-actions {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .email-dual-list {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .email-list-arrow {
        padding-top: 0;
        transform: rotate(90deg);
    }

    .calendar-day {
        min-height: 64px;
        padding: 4px;
    }

    .weekday {
        font-size: 0.625rem;
        padding: 8px 2px;
    }

    .day-number {
        font-size: 0.8125rem;
    }

    .calendar-month-label {
        font-size: 1.0625rem;
    }

    .upcoming-section,
    .calendar-section {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .calendar-day {
        min-height: 48px;
    }

    .reminder-dot {
        width: 6px;
        height: 6px;
    }

    .reminder-count {
        font-size: 0.5625rem;
        padding: 0 4px;
    }

    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}
