/*
  Mobile Smart Cards
  Kartenbasierte Ansicht für Warenwirtschaft auf Mobile
  Ersetzt Tabellen für bessere Touch-Bedienung
*/

/* === Smart Card Container === */
.smart-cards-container {
    display: none;
    /* Hidden by default, shown on mobile */
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3);
}

@media (max-width: 768px) {

    /* Show cards, hide tables on mobile */
    .smart-cards-container {
        display: flex;
    }

    /* Hide tables when cards are active */
    .mobile-cards-active .table-container,
    .mobile-cards-active table {
        display: none !important;
    }
}

/* === Smart Card Base === */
.smart-card {
    background: var(--color-surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    animation: fade-in-up 0.3s ease-out;
    animation-fill-mode: backwards;
    position: relative;
    /* For Selection overlays */
}

/* Selected state for deletion logic */
.smart-card.selected {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.1) !important;
}

.smart-card.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--color-primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

/* Staggered animation for list */
.smart-card:nth-child(1) {
    animation-delay: 0ms;
}

.smart-card:nth-child(2) {
    animation-delay: 50ms;
}

.smart-card:nth-child(3) {
    animation-delay: 100ms;
}

.smart-card:nth-child(4) {
    animation-delay: 150ms;
}

.smart-card:nth-child(5) {
    animation-delay: 200ms;
}

.smart-card:active {
    transform: scale(0.98);
    border-color: var(--color-gold-accent);
}

/* === Card Header === */
.smart-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border-subtle);
}

.smart-card__title-group {
    flex: 1;
    min-width: 0;
}

.smart-card__id {
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.smart-card__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: var(--space-1) 0 0 0;
    line-height: 1.3;
    /* Truncate long names */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.smart-card__unit {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
}

/* === Stock Display === */
.smart-card__stock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
}

.smart-card__stock-label {
    font-size: 12px;
    color: var(--color-text-muted);
}

.smart-card__stock-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-gold-accent);
}

.smart-card__stock-value--critical {
    color: var(--color-error);
}

.smart-card__stock-value--warning {
    color: var(--color-warning);
}

.smart-card__stock-value--good {
    color: var(--color-success);
}

/* === Helper Classes for Text === */
.text-error {
    color: var(--color-error);
}

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

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

.font-bold {
    font-weight: 700;
}

.text-right {
    text-align: right;
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.125rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

.pt-2 {
    padding-top: 0.5rem;
}

.border-t {
    border-top: 1px solid var(--color-border-subtle);
}

.border-glass {
    border-color: rgba(255, 255, 255, 0.1);
}

.badge-gold {
    background: rgba(212, 175, 55, 0.1);
    color: var(--color-gold-accent);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}


/* === Movement Card Specifics === */
.smart-card--movement .smart-card__main-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 8px 0;
}

.smart-card--movement .smart-card__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.smart-card--movement .smart-card__type-badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-surface-elevated);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--color-text-muted);
}

.smart-card--movement .smart-card__detail {
    display: flex;
    flex-direction: column;
}

.smart-card--movement .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--color-text-muted);
}


/* === Time Tracking Card Specifics === */
.smart-card--time .smart-card__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.smart-card--time .smart-card__hours-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.smart-card--time .smart-card__time-range {
    display: flex;
    align-items: center;
    background: var(--color-surface-elevated);
    padding: 8px 12px;
    border-radius: 8px;
    width: 100%;
    justify-content: center;
}

.smart-card--time .smart-card__footer {
    display: flex;
    justify-content: flex-start;
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border-subtle);
}

/* Extra time badge - prominent display next to hours */
.badge-extra {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.25) 0%, rgba(255, 215, 100, 0.15) 100%);
    color: var(--color-gold-accent);
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid rgba(212, 175, 55, 0.4);
}

/* Location - prominent display with larger font and accent color */
.smart-card__location {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-gold-accent);
}


/* === Input Section (Legacy Provisioning) === */
.smart-card__input-section {
    display: flex;
    gap: var(--space-3);
    align-items: stretch;
    margin-top: var(--space-3);
}

.smart-card__input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.smart-card__input-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.smart-card__input {
    width: 100%;
    height: var(--touch-large);
    background: var(--color-surface-base);
    border: 2px solid var(--color-border-default);
    border-radius: var(--radius-md);
    padding: 0 var(--space-3);
    font-family: var(--font-primary);
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    color: var(--color-text-primary);
    transition: all var(--transition-fast);
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
}

.smart-card__input::-webkit-inner-spin-button,
.smart-card__input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.smart-card__input:focus {
    outline: none;
    border-color: var(--color-gold-accent);
    box-shadow: 0 0 0 4px var(--color-gold-subtle);
}

.smart-card__input--filled {
    background: var(--color-gold-subtle);
    border-color: var(--color-gold-accent);
}

/* === Location Select === */
.smart-card__select-group {
    flex: 1;
}

.smart-card__select {
    width: 100%;
    height: var(--touch-comfortable);
    background: var(--color-surface-base);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    padding: 0 var(--space-3);
    font-family: var(--font-primary);
    font-size: 14px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.smart-card__select:focus {
    outline: none;
    border-color: var(--color-gold-accent);
}

/* === Card Footer / Meta === */
.smart-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border-subtle);
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* === Card Details (Subtle Secondary Info) === */
.smart-card__details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.smart-card__detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.smart-card__detail-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--color-text-muted);
    opacity: 0.6;
    margin-bottom: 2px;
}

.smart-card__detail-value {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-secondary);
    opacity: 0.7;
}

.smart-card__calculated {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.smart-card__new-stock-label {
    color: var(--color-text-muted);
}

.smart-card__new-stock-value {
    font-weight: 600;
    color: var(--color-text-primary);
    background: var(--color-surface-elevated);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

/* === Search/Filter Bar === */
.smart-cards-search {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: var(--space-3);
    background: var(--color-surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin: calc(-1 * var(--space-3));
    margin-bottom: var(--space-3);
}

.smart-cards-search__input {
    width: 100%;
    height: var(--touch-comfortable);
    background: var(--color-surface-base);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-full);
    padding: 0 var(--space-4);
    padding-left: 44px;
    font-family: var(--font-primary);
    font-size: 16px;
    color: var(--color-text-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
}

.smart-cards-search__input:focus {
    outline: none;
    border-color: var(--color-gold-accent);
}

.smart-cards-search__input::placeholder {
    color: var(--color-text-muted);
}

/* === Empty State === */
.smart-cards-empty {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    color: var(--color-text-secondary);
}

.smart-cards-empty__icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.smart-cards-empty__text {
    font-size: 16px;
    margin: 0;
}

/* === Floating Action Button for Batch Booking === */
.smart-cards-fab {
    position: fixed;
    bottom: calc(var(--touch-lg) + var(--space-8) + 16px);
    /* Above bottom nav */
    right: var(--space-4);
    min-width: 100px;
    height: var(--touch-large);
    background: linear-gradient(135deg, var(--color-gold-accent) 0%, var(--color-gold-muted) 100%);
    color: #1a1a1a;
    border: none;
    border-radius: var(--radius-full);
    padding: 0 var(--space-5);
    font-family: var(--font-primary);
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    box-shadow: var(--shadow-lg), var(--shadow-glow-gold);
    z-index: 100;
    transition: all var(--transition-fast);
}

.smart-cards-fab--danger {
    background: var(--color-error);
    color: white;
    box-shadow: var(--shadow-lg);
}

.smart-cards-fab:active {
    transform: scale(0.95);
}

.smart-cards-fab:disabled {
    background: var(--color-surface-elevated);
    color: var(--color-text-muted);
    box-shadow: var(--shadow-sm);
}

/* === Success State for Card === */
.smart-card--success {
    border-color: var(--color-success) !important;
    background: var(--color-success-bg) !important;
}

.smart-card--success .smart-card__input {
    border-color: var(--color-success);
    background: var(--color-success-bg);
}