/* Reseller Portal App-like Styles */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

* {
    box-sizing: border-box;
}

body.reseller-portal-page {
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
}

.reseller-portal {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
}

/* Header */
.reseller-portal h2 {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 2rem 0;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Fallback for browsers that don't support background-clip: text */
@supports not (-webkit-background-clip: text) {
    .reseller-portal h2 {
        color: var(--primary-color);
        background: none;
        -webkit-text-fill-color: unset;
    }
}

/* Card Components */
.portal-card {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.portal-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.portal-card h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-card h3::before {
    content: '';
    width: 4px;
    height: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 2px;
}

.portal-card h4 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
}

.portal-card p {
    color: var(--text-primary);
    margin: 0.5rem 0;
}

.portal-card ul {
    color: var(--text-primary);
}

.portal-card li {
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

/* Balance Section */
.reseller-balance {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
}

.reseller-balance::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: rotate(45deg);
}

.reseller-balance h3 {
    color: white !important;
    margin-bottom: 0.5rem;
}

.reseller-balance h3::before {
    background: rgba(255, 255, 255, 0.3);
}

.reseller-balance p {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    position: relative;
    z-index: 1;
    color: white !important;
}

/* Grid Layout for Cards */
.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    background: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    gap: 0.25rem;
}

.tab-button {
    flex: 1;
    min-width: 140px;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.tab-button:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.tab-button.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.tab-icon {
    font-size: 1rem;
}

/* Tab Content */
.tab-content {
    position: relative;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-pane.active {
    display: block;
}

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

/* Available Products */
.reseller-available-products {
    grid-column: 1 / -1;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.product-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.product-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}

.product-card:hover::before {
    transform: scaleX(1);
}

.product-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.product-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.product-price {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.product-action {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state p {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-secondary);
}

/* Table Container */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* Tables */
.portal-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-background);
    margin: 0;
}

.portal-table th {
    background: var(--background-color);
    color: var(--text-primary);
    font-weight: 600;
    padding: 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.portal-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    color: var(--text-primary);
}

.portal-table tr:hover {
    background-color: var(--background-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: white !important;
    text-decoration: none;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white !important;
}

.btn-secondary:hover {
    background: #475569;
    color: white !important;
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color) !important;
    border: 1px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white !important;
    text-decoration: none;
}

.show-order-details {
    background: var(--primary-color);
    color: white !important;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.show-order-details:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    color: white !important;
}

/* Order Details */
.order-details {
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

.order-details td {
    padding: 0;
    background: var(--background-color);
}

.order-details.show td {
    padding: 1.5rem;
}

.order-details-content {
    background: var(--card-background);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1rem;
    box-shadow: var(--shadow-sm);
}

.order-details-content h4 {
    color: var(--text-primary);
    font-weight: 600;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.order-details-content p {
    color: var(--text-primary);
}

.order-details-content ul {
    color: var(--text-primary);
}

.order-details-content li {
    color: var(--text-primary);
}

.order-details-content strong {
    color: var(--text-primary);
}

.order-details-content code {
    background: var(--background-color);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    border: 1px solid var(--border-color);
}

/* QR Code Display */
.qr-code-container {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
    text-align: center;
}

.qr-code-container img {
    max-width: 200px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.qr-code-container p {
    color: var(--text-primary);
}

.qr-code-container strong {
    color: var(--text-primary);
}

/* Phone number styling */
.qr-code-container .phone-number {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--background-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-left: 0.5rem;
}

/* PIN code styling */
.qr-code-container .pin-code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--warning-color);
    background: #fef3c7;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-left: 0.5rem;
    border: 1px solid #fbbf24;
}

/* Status Indicators */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-completed {
    background: #dcfce7;
    color: #166534;
}

.status-processing {
    background: #fef3c7;
    color: #92400e;
}

.status-pending {
    background: #e0e7ff;
    color: #3730a3;
}

/* eSIM Usage Links */
.mark-esim {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.mark-esim:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.iccid-status {
    color: var(--success-color);
    font-weight: 500;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .reseller-portal {
        padding: 0.5rem;
    }
    
    .portal-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .reseller-portal h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .portal-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .product-grid {
        grid-template-columns: 1fr;
    }
    
    /* Mobile Tab Navigation */
    .tab-navigation {
        padding: 0.25rem;
        gap: 0.125rem;
    }
    
    .tab-button {
        min-width: 120px;
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .tab-icon {
        font-size: 1.25rem;
    }
    
    /* Mobile Table - Complete redesign for better mobile experience */
    .table-container {
        border: none;
        overflow: visible;
    }
    
    .portal-table {
        border: none;
        box-shadow: none;
        background: transparent;
        width: 100%;
    }
    
    .portal-table,
    .portal-table thead,
    .portal-table tbody,
    .portal-table th,
    .portal-table td,
    .portal-table tr {
        display: block;
        width: 100%;
    }
    
    .portal-table thead {
        display: none;
    }
    
    .portal-table tr {
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
        padding: 1rem;
        background: var(--card-background);
        box-shadow: var(--shadow-sm);
        position: relative;
        width: 100%;
    }
    
    .portal-table td {
        border: none;
        border-bottom: 1px solid var(--border-color);
        position: relative;
        padding: 0.75rem 0;
        min-height: 2.5rem;
        display: block;
        color: var(--text-primary);
        width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .portal-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .portal-table td:first-child {
        padding-top: 0;
    }
    
    .portal-table td:before {
        content: attr(data-label) ": ";
        display: block;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        margin-bottom: 0.25rem;
        line-height: 1.2;
    }
    
    /* Mobile table content styling */
    .portal-table td .btn,
    .portal-table td .show-order-details {
        margin-top: 0.5rem;
        width: 100%;
        justify-content: center;
    }
    
    .portal-table td .status-badge {
        margin-top: 0.25rem;
        display: inline-block;
    }
    
    /* Order details mobile improvements */
    .order-details td {
        padding: 0 !important;
        border: none !important;
    }
    
    .order-details td:before {
        display: none !important;
    }
    
    .order-details-content {
        margin: 0.5rem;
        padding: 1rem;
        width: calc(100% - 1rem);
    }
    
    /* QR Code container mobile improvements */
    .qr-code-container {
        margin: 0.5rem 0;
        padding: 0.75rem;
        width: 100%;
    }
    
    .qr-code-container img {
        max-width: 150px;
        width: 100%;
        height: auto;
    }
    
    /* Balance History specific mobile styles */
    .tab-pane#balance-history .portal-table td {
        font-size: 0.9rem;
    }
    
    /* Order History specific mobile styles */
    .tab-pane#order-history .portal-table td {
        font-size: 0.85rem;
    }
    
    /* Ensure proper spacing for mobile content */
    .portal-table td > * {
        max-width: 100%;
        word-wrap: break-word;
    }
    
    /* Price formatting on mobile */
    .portal-table td .woocommerce-Price-amount {
        font-weight: 600;
        color: var(--primary-color);
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .reseller-portal {
        padding: 0.25rem;
    }
    
    .portal-card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .reseller-portal h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .tab-button {
        min-width: 100px;
        padding: 0.5rem;
        font-size: 0.7rem;
    }
    
    .portal-table tr {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .portal-table td {
        font-size: 0.8rem;
        padding: 0.5rem 0;
    }
    
    .portal-table td:before {
        font-size: 0.7rem;
        margin-bottom: 0.2rem;
    }
    
    .qr-code-container img {
        max-width: 120px;
    }
    
    .order-details-content {
        padding: 0.75rem;
        margin: 0.25rem;
        width: calc(100% - 0.5rem);
    }
}

/* PWA specific styles */
.pwa-install-prompt {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    background: var(--card-background);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    max-width: 400px;
    margin: 0 auto;
    animation: slideUp 0.3s ease-out;
}

.pwa-install-prompt.show {
    display: block;
}

.pwa-install-prompt h4 {
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.pwa-install-prompt p {
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

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

.pwa-install-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.pwa-install-buttons .btn {
    flex: 1;
    justify-content: center;
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--warning-color);
    color: white;
    text-align: center;
    padding: 0.5rem;
    font-weight: 500;
    z-index: 1001;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* Logout button in portal header */
.reseller-portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.reseller-portal-header .btn {
    margin-left: auto;
    margin-top: 0.5rem;
    white-space: nowrap;
}
@media (max-width: 600px) {
    .reseller-portal-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .reseller-portal-header .btn {
        margin-left: 0;
        margin-top: 1rem;
        width: 100%;
    }
}
