/* ============================================
   Raja Parcel - Shared Component Styles
   Android Native-style Animations
   Theme: Merah, Putih, Kuning
   ============================================ */

/* ===== CSS Variables ===== */
:root {
    --rp-red: #DC2626;
    --rp-red-dark: #B91C1C;
    --rp-red-light: #FEE2E2;
    --rp-red-50: #FEF2F2;
    --rp-yellow: #F59E0B;
    --rp-yellow-dark: #D97706;
    --rp-yellow-light: #FEF3C7;
    --rp-white: #FFFFFF;
    --rp-gray-50: #F9FAFB;
    --rp-gray-100: #F3F4F6;
    --rp-gray-200: #E5E7EB;
    --rp-gray-300: #D1D5DB;
    --rp-gray-400: #9CA3AF;
    --rp-gray-500: #6B7280;
    --rp-gray-600: #4B5563;
    --rp-gray-700: #374151;
    --rp-gray-800: #1F2937;
    --rp-gray-900: #111827;
    --rp-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --rp-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --rp-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --rp-radius: 12px;
    --rp-radius-sm: 8px;
    --rp-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Loading Overlay ===== */
#rp-loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#rp-loading-overlay.active {
    opacity: 1;
}

.rp-loading-content {
    background: white;
    border-radius: var(--rp-radius);
    padding: 2rem 2.5rem;
    text-align: center;
    box-shadow: var(--rp-shadow-xl);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#rp-loading-overlay.active .rp-loading-content {
    transform: scale(1);
}

.rp-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--rp-gray-200);
    border-top-color: var(--rp-red);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

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

.rp-loading-text {
    color: var(--rp-gray-600);
    font-size: 0.95rem;
    font-weight: 500;
    margin: 0;
}

/* ===== Modal Overlay ===== */
.rp-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.rp-modal-overlay.active {
    opacity: 1;
}

.rp-modal-container {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    max-height: calc(100vh - 2rem);
    overflow: auto;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(40px) scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rp-modal-sm { max-width: 360px; }
.rp-modal-md { max-width: 520px; }
.rp-modal-lg { max-width: 760px; }
.rp-modal-xl { max-width: min(1100px, 96vw); }

.rp-modal-html {
    text-align: left;
    margin: 0 0 1rem;
}

.rp-modal-overlay.active .rp-modal-container {
    transform: translateY(0) scale(1);
}

.rp-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
}

.rp-modal-icon svg {
    width: 100%;
    height: 100%;
}

.rp-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--rp-gray-900);
    margin: 0 0 0.5rem;
}

.rp-modal-message {
    font-size: 0.95rem;
    color: var(--rp-gray-500);
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

.rp-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.rp-modal-btn {
    padding: 0.7rem 1.5rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rp-transition);
    border: none;
    flex: 1;
    max-width: 200px;
}

.rp-modal-btn-confirm {
    background: linear-gradient(135deg, var(--rp-red), var(--rp-red-dark));
    color: white;
}

.rp-modal-btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.rp-modal-btn-cancel {
    background: var(--rp-gray-100);
    color: var(--rp-gray-700);
}

.rp-modal-btn-cancel:hover {
    background: var(--rp-gray-200);
}

/* ===== Form Modal ===== */
.rp-form-modal-sm { max-width: 360px; }
.rp-form-modal-md { max-width: 480px; }
.rp-form-modal-lg { max-width: 600px; }

.rp-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rp-gray-200);
}

.rp-form-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--rp-gray-400);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.rp-form-close:hover {
    color: var(--rp-gray-700);
}

.rp-form-body {
    text-align: left;
}

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

.rp-form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rp-gray-700);
    margin-bottom: 0.4rem;
}

.rp-form-input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--rp-gray-200);
    border-radius: var(--rp-radius-sm);
    font-size: 0.95rem;
    color: var(--rp-gray-800);
    background: var(--rp-gray-50);
    transition: var(--rp-transition);
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

.rp-form-input:focus {
    border-color: var(--rp-red);
    background: white;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

select.rp-form-input {
    cursor: pointer;
}

textarea.rp-form-input {
    resize: vertical;
    min-height: 80px;
}

.rp-form-input[readonly],
.rp-form-input:disabled {
    background: #F3F4F6;
    color: #6B7280;
    cursor: not-allowed;
}

.rp-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.25rem;
    border: 1.5px solid var(--rp-gray-200);
    border-radius: var(--rp-radius-sm);
    background: #FAFAFA;
}

.rp-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    background: white;
    border: 1px solid var(--rp-gray-200);
    color: var(--rp-gray-700);
    font-size: 0.85rem;
}

.rp-checkbox-item input {
    accent-color: var(--rp-red);
}

/* ===== Toast ===== */
#rp-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: min(100vw - 1.5rem, 380px);
}

.rp-toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.95rem 1rem 1rem;
    border-radius: 16px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
    transform: translate3d(120%, 0, 0);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.rp-toast.active {
    transform: translate3d(0, 0, 0);
}

.rp-toast-success { background: linear-gradient(135deg, #166534, #16A34A); }
.rp-toast-error { background: linear-gradient(135deg, #B91C1C, #DC2626); }
.rp-toast-warning { background: linear-gradient(135deg, #B45309, #F59E0B); }
.rp-toast-info { background: linear-gradient(135deg, #1D4ED8, #2563EB); }

.rp-toast-icon-wrap {
    flex-shrink: 0;
}

.rp-toast-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.16);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

.rp-toast-icon svg {
    width: 20px;
    height: 20px;
}

.rp-toast-content {
    flex: 1;
    min-width: 0;
}

.rp-toast-title {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    margin-bottom: 0.15rem;
}

.rp-toast-message {
    font-size: 0.82rem;
    line-height: 1.45;
    color: rgba(255,255,255,0.9);
}

.rp-toast-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255,255,255,0.12);
    color: white;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.rp-toast-close:hover {
    background: rgba(255,255,255,0.22);
    transform: scale(1.05);
}

.rp-toast-close svg {
    width: 14px;
    height: 14px;
}

.rp-toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(255,255,255,0.22);
    transform-origin: left center;
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 640px) {
    #rp-toast-container {
        top: auto;
        right: 0.75rem;
        left: 0.75rem;
        bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
        width: auto;
    }

    .rp-toast {
        transform: translate3d(0, 120%, 0);
    }
}

/* ===== Badges ===== */
.rp-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.rp-badge-success { background: #DCFCE7; color: #166534; }
.rp-badge-danger { background: #FEE2E2; color: #991B1B; }
.rp-badge-warning { background: #FEF3C7; color: #92400E; }
.rp-badge-info { background: #DBEAFE; color: #1E40AF; }

/* ===== Empty State ===== */
.rp-empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--rp-gray-400);
}

.rp-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

.rp-empty-state p {
    font-size: 0.95rem;
    margin: 0;
}

/* ===== Animate Utilities ===== */
.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

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

.animate-slide-up {
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--rp-gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--rp-gray-400);
}
