/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-secondary {
    background-color: #fff;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.btn-danger {
    background-color: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

.btn-danger:hover {
    background-color: #fecaca;
}

.btn-mini {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    font-family: inherit;
    width: 100%;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Header Image Container imports from Style css */
.header-image-container {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    flex-shrink: 0 !important;
    background: #f1f5f9;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    overflow: hidden !important;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.header-image-container img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.header-image-container.has-image {
    background: white;
    border-color: transparent;
}

.modal-header h2 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-primary);
}

.header-right-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--primary-color);
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f1f5f9;
}

.close-modal:not(.btn) {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal:not(.btn):hover {
    background-color: #f1f5f9;
    color: var(--primary-color);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    background-color: #f8fafc;
    transition: all 0.2s;
}

.image-upload-area:hover {
    border-color: var(--primary-color);
    background-color: #fff;
}

.modal-actions {
    padding: 1rem 1.5rem;
    background-color: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
}

.modal-actions .btn {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    height: 34px;
}

/* Table Sorting & Filtering */
.data-table th {
    transition: background-color 0.2s;
    user-select: none;
    vertical-align: top;
}

.data-table th:hover {
    background-color: #f1f5f9;
}

.data-table th span i {
    font-size: 0.8rem;
    color: var(--primary-color);
}

.column-filter-input:focus {
    border-color: var(--primary-color) !important;
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* Toasts */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background-color: white;
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    transform: translateX(120%);
    animation: slideInToast 0.3s forwards cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.3s;
    border-left: 4px solid var(--primary-color);
    pointer-events: auto;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.info {
    border-left-color: #f59e0b;
    /* Yellow for indicative items */
}

@keyframes slideInToast {
    to {
        transform: translateX(0);
    }
}

/* Mobile Adjustments for Components */
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100dvh;
        max-width: 100%;
        max-height: 100dvh;
        border-radius: 0;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-group.full-width {
        grid-column: auto;
    }

    .modal-actions {
        flex-direction: row;
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding: 1rem 1.25rem 1.75rem !important;
        /* Fixed clipping */
    }

    .modal-actions .btn {
        width: 100%;
        height: 46px !important;
        font-size: 0.95rem !important;
    }

    #toast-container {
        right: 1rem;
        left: 1rem;
        bottom: 5rem;
    }

    .toast {
        min-width: 0;
    }
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Tab Pills (used in Transit/Logistics) */
.tab-pills {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.pill {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.pill:hover {
    color: var(--text-primary);
    background: white;
}

.pill.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Image Cell Fixes */
.cell-image {
    display: inline-block;
    cursor: pointer;
    z-index: 5;
    position: relative;
    transition: transform 0.1s;
}

.cell-image img {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    background-color: #f1f5f9;
}

.cell-image-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    position: relative;
}

.image-count-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: white !important;
    color: black !important;
    font-size: 0.70rem;
    font-weight: 800;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
    pointer-events: none;
    border: 1px solid #e2e8f0;
}