/**
 * VetPOP Utility Classes
 * Reusable CSS patterns to replace inline styles
 */

/* ============================================================================
   LAYOUT UTILITIES
   ============================================================================ */

.container-max {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-start {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* ============================================================================
   NAVIGATION & HEADERS
   ============================================================================ */

.nav-bar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0 0.25rem;
    height: 100%;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--color-text-primary);
    border-bottom-color: var(--color-border-focus);
}

.nav-link.active {
    color: var(--color-text-primary);
    border-bottom-color: var(--brand-primary-from);
}

/* ============================================================================
   CARDS & SURFACES
   ============================================================================ */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.card-elevated {
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.card-hover {
    transition: box-shadow 0.2s, transform 0.2s;
}

.card-hover:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary-from), var(--brand-primary-to));
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--color-button-background);
    color: var(--color-button-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-background-alt);
    border-color: var(--color-border-focus);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-primary);
}

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

.btn-icon {
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    background: transparent;
}

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

/* ============================================================================
   FORMS & INPUTS
   ============================================================================ */

.input {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text-primary);
    background: var(--color-input-background);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.input:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

.input:disabled {
    background: var(--color-background-alt);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Select element specific styling */
select.input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

select.input option {
    background: var(--color-surface);
    color: var(--color-text-primary);
    padding: 0.5rem;
}

.label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

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

/* ============================================================================
   ALERTS & MESSAGES
   ============================================================================ */

.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid;
    margin-bottom: 1rem;
}

.alert-error {
    background: var(--color-error-bg);
    border-color: var(--color-error);
    color: var(--color-error);
}

.alert-success {
    background: var(--color-success-bg);
    border-color: var(--color-success);
    color: var(--color-success);
}

.alert-warning {
    background: var(--color-warning-bg);
    border-color: var(--color-warning);
    color: var(--color-warning);
}

.alert-info {
    background: var(--color-info-bg);
    border-color: var(--color-info);
    color: var(--color-info);
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-primary {
    background: var(--color-primary-alpha);
    color: var(--color-primary);
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-error {
    background: var(--color-error-bg);
    color: var(--color-error);
}

.badge-info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

/* ============================================================================
   DROPDOWN MENUS
   ============================================================================ */

.dropdown-menu {
    position: absolute;
    right: 0;
    margin-top: 0.5rem;
    width: 12rem;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 0.25rem;
    z-index: 50;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--color-text-primary);
    text-align: left;
    border-radius: 0.375rem;
    transition: background 0.2s;
}

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

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

.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-background-alt) 0%,
        var(--color-border) 50%,
        var(--color-background-alt) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.25rem;
}

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

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

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

.divider-vertical {
    width: 1px;
    height: 100%;
    background: var(--color-border);
    margin: 0 1rem;
}

/* ============================================================================
   TEXT UTILITIES
   ============================================================================ */

.text-primary {
    color: var(--color-text-primary);
}

.text-secondary {
    color: var(--color-text-secondary);
}

.text-muted {
    color: var(--color-text-muted);
}

.text-gradient {
    background: linear-gradient(135deg, var(--brand-primary-from), var(--brand-primary-to));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================================================
   TRANSITIONS
   ============================================================================ */

.transition-all {
    transition: all 0.2s ease-in-out;
}

.transition-colors {
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.transition-transform {
    transition: transform 0.2s ease-in-out;
}

/* ============================================================================
   RESPONSIVE UTILITIES
   ============================================================================ */

.hide-mobile {
    display: none;
}

@media (min-width: 640px) {
    .hide-mobile {
        display: block;
    }

    .hide-desktop {
        display: none;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

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

/* ============================================================================
   PERMISSION SELECTION
   ============================================================================ */

.permission-card {
    position: relative;
}

.permission-card.permission-selected {
    background: var(--color-primary-alpha) !important;
    border-color: var(--brand-primary-from) !important;
    box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

.permission-card.permission-selected .permission-check-icon {
    display: block !important;
}

.permission-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* ============================================================================
   TOGGLE SWITCHES
   ============================================================================ */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-background-alt);
    border: 2px solid var(--color-border);
    transition: all 0.3s ease;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--color-text-secondary);
    transition: all 0.3s ease;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--brand-primary-from), var(--brand-primary-to));
    border-color: var(--brand-primary-from);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background: white;
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

.toggle-switch:hover .toggle-slider {
    border-color: var(--color-border-focus);
}

/* ============================================================================
   BUTTON SIZE VARIANTS
   ============================================================================ */

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.813rem;
    line-height: 1.25rem;
}

.btn-xs {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    line-height: 1rem;
}
