/* =========================================================================
   Card System - Unified card components
   ========================================================================= */

/**
 * CARD SYSTEM
 *
 * Base:     .card                 - Glass background, border, hover effect
 *
 * Variants:
 *   .card--subtle                 - Subtle hover (1px lift)
 *   .card--flat                   - No lift, border highlight only
 *   .card--solid                  - Solid background
 *   .card--row                    - Compact row layout (12px padding)
 *   .card--rows                   - Container for .setting-row elements (no padding, overflow hidden)
 *   .card--interactive            - Cursor pointer
 *   .card--static                 - No hover effect
 *
 * Layout elements:
 *   .card-drag                    - Drag handle
 *   .card-icon                    - Icon container (44x44)
 *   .card-icon--sm                - Small icon (36x36)
 *   .card-icon--lg                - Large icon (48x48)
 *   .card-icon--round             - Round icon
 *   .card-icon--gradient          - Gradient background (use with .profile/.users/etc)
 *   .card-body                    - Main content (flex: 1)
 *   .card-title                   - Title (15px bold)
 *   .card-subtitle                - Subtitle (12px muted)
 *   .card-value                   - Large value (18px bold) for stats
 *   .card-label                   - Small label (11px muted)
 *   .card-badges                  - Badge container
 *   .card-end                     - Right side container
 *   .card-actions                 - Action buttons (opacity on hover)
 *   .card-chevron                 - Chevron arrow (animates on hover)
 *
 * NOTE: For dropdown menus on cards, use the unified dropdown component
 *       (.dropdown with .dropdown-trigger--icon) from dropdown.css
 */

/* Base Card */
.card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--ip-bg-glass);
    border: 1px solid var(--ip-border);
    border-radius: var(--ip-radius-sm);
    transition: all 0.2s ease;
}

.card:hover {
    background: var(--ip-bg-glass-hover);
    transform: translateY(-2px);
    box-shadow: var(--ip-shadow);
}

/* Disable transform when dropdown is open (fixes fixed positioning inside transformed element) */
.card:has(.dropdown.open) {
    transform: none;
}

/* Subtle hover (1px lift) - recommended for lists */
.card--subtle:hover {
    transform: translateY(-1px);
    box-shadow: var(--ip-shadow-sm);
}

/* Flat hover - no lift, border highlight */
.card--flat:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--ip-primary);
}

/* Solid background */
.card--solid {
    background: var(--ip-bg-solid);
    border-color: var(--ip-border-subtle);
}

.card--solid:hover {
    background: var(--ip-bg-glass-hover);
}

/* Row layout - compact padding */
.card--row {
    padding: 12px;
    gap: 12px;
    border-radius: var(--ip-radius-xs);
}

/* Interactive (clickable) */
.card--interactive {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

/* Static - no hover */
.card--static:hover {
    transform: none;
    box-shadow: none;
    background: var(--ip-bg-glass);
}

/* Rows container - for .setting-row form elements */
.card--rows {
    display: block;
    padding: 0;
    overflow: hidden;
}

.card--rows:hover {
    transform: none;
    box-shadow: none;
}

/* Danger variant for rows */
.card--rows.card--danger .setting-row {
    background: rgba(239, 68, 68, 0.05);
}

/* Inactive - faded appearance */
.card--inactive {
    opacity: 0.5;
}

/* -------------------------
   Card Layout Elements
   ------------------------- */

/* Drag handle */
.card-drag {
    cursor: grab;
    color: var(--ip-text-muted);
    padding: 4px;
    margin: -4px;
    flex-shrink: 0;
}

.card-drag:active {
    cursor: grabbing;
}

.card-drag svg {
    width: 16px;
    height: 16px;
}

/* Sortable.js drag states */
.sortable-ghost {
    opacity: 0.4;
    background: var(--ip-bg-glass);
}

.sortable-chosen {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sortable-drag {
    opacity: 1;
    background: var(--ip-bg-solid);
}

/* Icon container */
.card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ip-bg-glass);
    border-radius: var(--ip-radius-xs);
    color: var(--ip-primary);
    flex-shrink: 0;
}

.card-icon svg,
.card-icon i {
    width: 20px;
    height: 20px;
    font-size: 20px;
}

/* Icon sizes */
.card-icon--sm {
    width: 36px;
    height: 36px;
}

.card-icon--sm svg,
.card-icon--sm i {
    width: 18px;
    height: 18px;
    font-size: 18px;
}

.card-icon--lg {
    width: 48px;
    height: 48px;
}

.card-icon--lg svg,
.card-icon--lg i {
    width: 24px;
    height: 24px;
    font-size: 24px;
}

/* Round icon */
.card-icon--round {
    border-radius: 50%;
    border: 2px solid var(--ip-border);
}

.card-icon--round img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gradient icon backgrounds */
.card-icon--gradient {
    color: white;
}

.card-icon--gradient.blue {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
}

.card-icon--gradient.green {
    background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
}

.card-icon--gradient.orange {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
}

.card-icon--gradient.pink {
    background: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%);
}

.card-icon--gradient.purple {
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
}

/* Icon color variants */
.card-icon--success {
    color: var(--ip-success);
}

/* Preview icon (screen thumbnail) */
.card-icon--preview {
    width: 48px;
    height: 36px;
    border-radius: 4px;
    color: var(--ip-text-muted);
}

/* Brand icons (size variant for integrations) */
.card-icon--brand {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

/* Connected state */
.card--connected {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.02);
}

/* Main content area */
.card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Title */
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ip-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Subtitle */
.card-subtitle {
    font-size: 12px;
    color: var(--ip-text-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Large value (for stats) */
.card-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--ip-text);
    line-height: 1.2;
}

/* Small label */
.card-label {
    font-size: 11px;
    color: var(--ip-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Badges container */
.card-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

/* Inline badge (not absolute positioned) */
.card-badges .badge,
.badge--inline {
    position: static;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    background: var(--ip-bg-glass);
    color: var(--ip-text-secondary);
    border-radius: 4px;
}

.card-badges .badge svg,
.badge--inline svg {
    width: 12px;
    height: 12px;
}

.badge--muted {
    background: var(--ip-bg-glass);
    color: var(--ip-text-muted);
}

.badge--warning {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

[data-theme="dark"] .badge--warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.badge--success {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
}

[data-theme="dark"] .badge--success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.badge--danger {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

[data-theme="dark"] .badge--danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* Right side container */
.card-end {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Action buttons - visible on hover */
.card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.card:hover .card-actions {
    opacity: 1;
}

/* Always visible actions */
.card-actions--visible {
    opacity: 1;
}

/* Chevron arrow (for navigation cards) */
.card-chevron {
    color: var(--ip-text-muted);
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.card-chevron svg {
    width: 20px;
    height: 20px;
}

.card:hover .card-chevron {
    transform: translateX(4px);
    color: var(--ip-primary);
}

/* Card menu is now handled by the unified dropdown component (dropdown.css)
   Use .dropdown with .dropdown-trigger--icon instead of .card-menu */

/* -------------------------
   Card with sections (header/body/footer)
   For more complex cards like calendar-card
   ------------------------- */
.card--sectioned {
    flex-direction: column;
    padding: 0;
    gap: 0;
}

.card--sectioned .card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    width: 100%;
}

.card--sectioned .card-section {
    padding: 12px 16px;
    border-top: 1px solid var(--ip-border-subtle);
}

.card--sectioned .card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    padding: 10px 16px;
    border-top: 1px solid var(--ip-border-subtle);
}

/* App Layout */
.app {
    display: flex;
    min-height: 100vh;
    padding: var(--ip-app-padding);
    gap: var(--ip-app-padding);
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-radius: var(--ip-radius);
    background: var(--ip-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--ip-border);
    box-shadow: var(--ip-shadow);
    overflow: hidden;
    position: sticky;
    top: var(--ip-app-padding);
    height: calc(100vh - 2 * var(--ip-app-padding));
}

/* Mobile: Sidebar becomes fixed overlay, removed from flex flow */
@media (max-width: 768px) {
    .sidebar:not(.sidebar--right) {
        position: fixed;
        top: 12px;
        left: 12px;
        right: 12px;
        bottom: auto;
        width: auto;
        height: auto;
        max-height: calc(100vh - 24px);
        z-index: 100;
        transform: translateY(-120%);
    }

    .sidebar:not(.sidebar--right).open {
        transform: translateY(0);
    }
}

