/* =============================================
   COMPONENTS.CSS - Buttons, Dropdowns, Modal, Toast, Forms
   ============================================= */

/* =============================================
   BUTTONS
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--duration-fast) var(--ease-out);
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--coral);
    outline-offset: 2px;
}

/* Primary Button - Coral accent */
.btn-primary {
    background: var(--coral);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--coral-deep);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary Button - Subtle outline */
.btn-secondary {
    background: var(--white);
    color: var(--ink);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--cream);
    border-color: var(--stone);
}

/* Ghost Button - Transparent */
.btn-ghost {
    background: transparent;
    color: var(--charcoal);
}

.btn-ghost:hover {
    background: var(--cream);
    color: var(--ink);
}

/* Danger Button */
.btn-danger {
    background: var(--phase-menstrual);
    color: var(--white);
}

.btn-danger:hover {
    background: #D46B63;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: 13px;
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: 15px;
}

/* Today Button (Special) */
.today-btn {
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--white);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    transition: all var(--duration-fast) var(--ease-out);
}

.today-btn:hover {
    background: var(--cream);
    border-color: var(--stone);
}

/* Icon Button */
.icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--charcoal);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.icon-btn:hover {
    background: var(--cream);
    color: var(--ink);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* =============================================
   DROPDOWNS
   ============================================= */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.dropdown-trigger:hover {
    background: var(--cream);
    border-color: var(--stone);
}

.dropdown-trigger svg {
    width: 16px;
    height: 16px;
    color: var(--warm-gray);
    transition: transform var(--duration-fast) var(--ease-out);
}

.dropdown.open .dropdown-trigger svg {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 180px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--duration-fast) var(--ease-out);
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}

.dropdown-item:hover {
    background: var(--cream);
}

.dropdown-item.active {
    background: var(--coral-soft);
    color: var(--coral-deep);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: var(--warm-gray);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-2) 0;
}

/* =============================================
   MODAL
   ============================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(45, 42, 38, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    padding: var(--space-4);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 440px;
    max-width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: modalIn var(--duration-normal) var(--ease-out);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 400;
    color: var(--ink);
}

.modal-close {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--warm-gray);
    transition: all var(--duration-fast) var(--ease-out);
}

.modal-close:hover {
    background: var(--cream);
    color: var(--ink);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--off-white);
}

.modal-footer-actions {
    display: flex;
    gap: var(--space-2);
}

/* =============================================
   FORM ELEMENTS
   ============================================= */

.form-group {
    margin-bottom: var(--space-4);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--warm-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--ink);
    background: var(--white);
    transition: all var(--duration-fast) var(--ease-out);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--stone);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--coral);
    box-shadow: 0 0 0 3px var(--coral-soft);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--stone);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239A9590' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-row {
    display: flex;
    gap: var(--space-3);
}

.form-row .form-group {
    flex: 1;
}

/* Checkbox */
.form-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.form-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--coral);
    cursor: pointer;
}

.form-checkbox span {
    font-size: 14px;
    color: var(--ink);
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: var(--space-2);
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--white), 0 0 0 4px currentColor;
}

.color-option.coral { background: var(--coral); }
.color-option.sage { background: var(--sage); }
.color-option.lavender { background: var(--lavender); }
.color-option.honey { background: var(--honey); }

/* =============================================
   TOAST NOTIFICATION
   ============================================= */

.toast {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--ink);
    color: var(--white);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    transition: transform var(--duration-normal) var(--ease-out);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.toast.active {
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    width: 18px;
    height: 18px;
}

.toast.success {
    background: var(--sage);
}

.toast.error {
    background: var(--phase-menstrual);
}

.toast.warning {
    background: var(--honey);
    color: var(--ink);
}

/* =============================================
   TOOLTIPS
   ============================================= */

.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: var(--space-2) var(--space-3);
    background: var(--ink);
    color: var(--white);
    font-size: 12px;
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-fast) var(--ease-out);
    z-index: 100;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--ink);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-fast) var(--ease-out);
}

.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* =============================================
   BADGES & TAGS
   ============================================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-coral {
    background: var(--coral-soft);
    color: var(--coral-deep);
}

.badge-sage {
    background: var(--sage-soft);
    color: #4A7A67;
}

.badge-lavender {
    background: var(--lavender-soft);
    color: #6B5F94;
}

.badge-honey {
    background: var(--honey-soft);
    color: #9A7D3B;
}

.badge-neutral {
    background: var(--cream);
    color: var(--charcoal);
}

/* Phase Badges */
.phase-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}

.phase-badge.menstrual {
    background: var(--phase-menstrual-light);
    color: var(--phase-menstrual);
}

.phase-badge.follicular {
    background: var(--phase-follicular-light);
    color: #C47D4A;
}

.phase-badge.ovulation {
    background: var(--phase-ovulation-light);
    color: #4A8A73;
}

.phase-badge.luteal {
    background: var(--phase-luteal-light);
    color: #6B5F94;
}

/* =============================================
   AVATAR
   ============================================= */

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--coral) 0%, var(--lavender) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    overflow: hidden;
}

.avatar:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 24px;
    height: 24px;
    font-size: 11px;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 20px;
}

/* =============================================
   SEARCH INPUT
   ============================================= */

.search-input {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--cream);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--ease-out);
    min-width: 200px;
}

.search-input:focus-within {
    background: var(--white);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.search-input svg {
    width: 16px;
    height: 16px;
    color: var(--warm-gray);
    flex-shrink: 0;
}

.search-input input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--ink);
    outline: none;
}

.search-input input::placeholder {
    color: var(--stone);
}

/* =============================================
   LOADING STATES
   ============================================= */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--cream) 0%,
        var(--off-white) 50%,
        var(--cream) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-pulse {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--cream);
    border-top-color: var(--coral);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =============================================
   EMPTY STATES
   ============================================= */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-10);
    text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-4);
    color: var(--stone);
    opacity: 0.5;
}

.empty-state-title {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--charcoal);
    margin-bottom: var(--space-2);
}

.empty-state-description {
    font-size: 14px;
    color: var(--warm-gray);
    max-width: 280px;
    line-height: 1.5;
}

/* =============================================
   DIVIDERS
   ============================================= */

.divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-4) 0;
}

.divider-vertical {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 var(--space-3);
}

.divider-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--warm-gray);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.divider-label::before,
.divider-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
