:root {
    --tabby-green: #3FD28B;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --text-disabled: #999999;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F2F2F7;
    --bg-disabled: #E5E5EA;
    --bg-notes: #FFF4E6;
    --text-notes: #8B6914;
    --button-active: #2C2C2C;
    --border-color: #E5E5EA;
}

.amwal-pos {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    width: 100%;
    max-width: 375px;
    min-height: 46vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

.pos-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.pos-screen.qr-screen {
    padding: 20px 20px 20px 20px;
}

/* Logo */
.pos-logo {
    padding: 20px 20px 20px 20px;
    display: flex;
    justify-content: flex-start;
}

/* Logo positioning for RTL */
.pos-logo.rtl {
    justify-content: flex-end;
}

.pos-logo.ltr {
    justify-content: flex-start;
}

/* Content */
.pos-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 20px;
}

.pos-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    margin: 0 0 20px 0;
    line-height: 1.2;
}

/* Amount Input */
.pos-amount-container {
    margin-bottom: 20px;
}

.pos-amount-input {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 16px;
    min-height: 20px;
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: 400;
    color: var(--text-primary);
}

.amount-text {
    width: 100%;
}

.amount-placeholder {
    width: 100%;
    color: var(--text-secondary);
}

.cursor {
    color: var(--text-primary);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Continue Button */
.pos-continue {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--bg-disabled);
    color: var(--text-disabled);
}

.pos-continue.active {
    background-color: var(--button-active);
    color: white;
}

.pos-continue:disabled {
    cursor: not-allowed;
}

/* Keypad */
.pos-keypad {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.pos-keypad-row {
    display: flex;
    gap: 12px;
}

.pos-key {
    flex: 1;
    height: 50px;
    border: none;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pos-key:active {
    background-color: var(--bg-disabled);
    transform: scale(0.95);
}

.pos-key.done {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
}

.pos-key.backspace svg {
    stroke: var(--text-primary);
    width: 18px;
    height: 14px;
}

/* Notes */
.pos-notes {
    background-color: var(--bg-notes);
    padding: 16px 20px 20px 20px;
    margin-top: auto;
}

.notes-content {
    text-align: center;
    font-size: 12px;
    color: var(--text-notes);
    line-height: 1.4;
}

/* QR Screen */
.qr-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

.qr-code {
    background-color: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.qr-pattern {
    display: block;
}

/* QR Actions */
.qr-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-bottom: 20px;
}

.pos-button {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pos-button.cancel {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.pos-button.cancel:active {
    background-color: var(--bg-secondary);
}

.pos-button.check-status {
    background-color: var(--button-active);
    color: white;
}

.pos-button.check-status:active {
    background-color: #1a1a1a;
}

/* Processing Screen */
.processing-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 40px 0;
}

.processing-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.processing-spinner::before {
    content: '';
    position: absolute;
    width: 72px;
    height: 72px;
    border: 2px solid var(--tabby-green);
    border-radius: 50%;
    opacity: 0.3;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.1;
    }
    100% {
        transform: scale(0.8);
        opacity: 0.3;
    }
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-disabled);
    border-top: 4px solid var(--tabby-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
    position: relative;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.processing-info {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.processing-amount {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.processing-message {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 280px;
    line-height: 1.4;
    animation: fadeInUp 0.5s ease-out 0.3s both;
}

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

/* Success Screen */
.success-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 40px 0;
}

.success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: successBounce 0.6s ease-out;
}

@keyframes successBounce {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.success-info {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.success-amount {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.success-message {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* Error Screen */
.error-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 40px 0;
}

.error-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: errorBounce 0.6s ease-out;
}

@keyframes errorBounce {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.error-info {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.error-amount {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.error-message {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    max-width: 280px;
    line-height: 1.4;
    animation: fadeInUp 0.5s ease-out 0.3s both;
}

.transaction-id {
    font-size: 12px;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    border: 1px solid var(--border-color);
    animation: slideIn 0.4s ease-out 0.2s both;
}

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

/* Enhanced button styling for success screen */
.success-container + .pos-continue {
    margin-top: 0;
    transform: translateY(0);
    animation: slideInButton 0.5s ease-out 0.4s both;
}

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

/* RTL Support */
[dir="rtl"] .amwal-pos {
    direction: rtl;
}

[dir="rtl"] .pos-amount-input {
    text-align: right;
}

[dir="rtl"] .notes-content {
    text-align: center;
}

/* RTL Support for Arabic */
.amwal-pos[dir="rtl"] .pos-logo {
    justify-content: start;
}

.amwal-pos[dir="rtl"] .pos-title {
    text-align: right;
}

.amwal-pos[dir="rtl"] .amount-text {
    text-align: right;
}

.amwal-pos[dir="rtl"] .amount-placeholder {
    text-align: right;
    direction: rtl;
}

.amwal-pos[dir="rtl"] .processing-info {
    text-align: center;
}

.amwal-pos[dir="rtl"] .success-info {
    text-align: center;
}

.amwal-pos[dir="rtl"] .error-info {
    text-align: center;
}

.amwal-pos[dir="rtl"] .transaction-id {
    text-align: center;
    direction: rtl;
}

.amwal-pos[dir="rtl"] .processing-message {
    text-align: center;
}

.amwal-pos[dir="rtl"] .success-message {
    text-align: center;
}

.amwal-pos[dir="rtl"] .error-message {
    text-align: center;
}

.amwal-pos[dir="rtl"] .notes-content {
    text-align: center;
    direction: rtl;
}

/* QR Actions RTL spacing */
.amwal-pos[dir="rtl"] .qr-actions {
    flex-direction: row-reverse;
}

/* Keypad number alignment for RTL */
.amwal-pos[dir="rtl"] .pos-key {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Responsive adjustments */
@media (max-width: 375px) {
    .pos-logo {
        padding: 16px 16px 16px 16px;
    }

    .pos-content {
        padding: 0 16px;
    }

    .pos-notes {
        padding: 12px 16px 16px 16px;
    }

    .pos-screen.qr-screen {
        padding: 16px 16px 16px 16px;
    }

    .qr-actions {
        padding-bottom: 16px;
    }

    .processing-container {
        padding: 20px 0;
        gap: 24px;
    }

    .processing-amount, .success-amount {
        font-size: 20px;
    }

    .success-container {
        padding: 20px 0;
        gap: 24px;
    }

    .success-icon svg {
        width: 64px;
        height: 64px;
    }
}

@media (max-width: 320px) {
    .pos-key {
        height: 46px;
        font-size: 16px;
    }

    .pos-keypad {
        gap: 10px;
    }

    .pos-keypad-row {
        gap: 10px;
    }

    .qr-code {
        padding: 12px;
    }

    .qr-pattern {
        width: 160px;
        height: 160px;
    }

    .processing-container {
        padding: 16px 0;
        gap: 20px;
    }

    .success-container {
        padding: 16px 0;
        gap: 20px;
    }

    .spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }

    .success-icon svg {
        width: 56px;
        height: 56px;
    }

    .processing-amount, .success-amount {
        font-size: 18px;
    }

    .processing-message {
        font-size: 13px;
    }

    .success-message {
        font-size: 14px;
    }
}

/* Larger screens */
@media (min-width: 768px) {
    .amwal-pos {
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
        margin: 20px auto;
        max-height: 85vh;
        min-height: 530px;
    }

    .processing-container {
        gap: 40px;
    }

    .success-container {
        gap: 40px;
    }

    .success-icon svg {
        width: 96px;
        height: 96px;
    }

    .processing-amount, .success-amount {
        font-size: 28px;
    }
}