/* Clean Modern Design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f8fafc;
    color: #334155;
    line-height: 1.6;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: #1e293b;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-link {
    color: #64748b;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover {
    color: #1e293b;
    background: #f1f5f9;
}

.nav-link.active {
    color: #3b82f6;
    background: #eff6ff;
}

.lang-switcher {
    display: flex;
    gap: 0.25rem;
    background: #f1f5f9;
    border-radius: 0.5rem;
    padding: 0.25rem;
}

.lang-btn {
    padding: 0.25rem 0.75rem;
    border: none;
    background: none;
    color: #64748b;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.lang-btn.active {
    background: #ffffff;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.page-header {
    text-align: center;
    margin-bottom: 3rem;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    font-size: 1.125rem;
    color: #64748b;
}

/* Cards */
.card {
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
}

.card-content {
    padding: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
    background: #ffffff;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
    background: #ffffff;
    resize: vertical;
    min-height: 100px;
}

.form-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-primary {
    background: #3b82f6;
    color: #ffffff;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-secondary {
    background: #6b7280;
    color: #ffffff;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: #ef4444;
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: #10b981;
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-outline:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background: #f8fafc;
}

/* --- Mobile Card View for Dashboard Table --- */
@media (max-width: 700px) {
    .table-container {
        width: 100%;
        overflow-x: visible;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .table {
        width: 100%;
        border: 0;
        table-layout: auto;
    }

    .table thead {
        display: none;
    }

    .table tbody {
        display: block;
    }

    .dashboard-row {
        display: block;
        margin-bottom: 1rem;
        background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        padding: 1rem;
        border: 1px solid #e2e8f0;
        position: relative;
        transition: all 0.3s ease;
    }

    .dashboard-row:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    .dashboard-row td {
        display: block;
        width: 100%;
        border: none;
        border-bottom: 1px solid #f1f5f9;
        position: relative;
        padding: 0.5rem 0;
        min-height: auto;
        box-sizing: border-box;
        text-align: left;
        background: none;
        box-shadow: none;
        font-size: 0.95em;
        word-break: break-word;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        line-height: 1.4;
        flex-direction: column;
    }

    .dashboard-row td:first-child {
        padding-top: 0;
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 0.25rem;
        padding-bottom: 0.5rem;
    }

    .dashboard-row td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-top: 0.25rem;
    }

    .dashboard-row td:before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: #475569;
        font-size: 0.8em;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        margin-bottom: 0.2rem;
    }

    .dashboard-row td:first-child:before {
        color: #1e293b;
        font-size: 0.85em;
        margin-bottom: 0.3rem;
    }

    /* Style the action buttons in mobile */
    .dashboard-row td:last-child {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        padding-top: 0.5rem;
        align-items: stretch;
    }

    .dashboard-row td:last-child .btn {
        flex: 1;
        text-align: center;
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
        border-radius: 6px;
        display: block;
        white-space: nowrap;
    }
}

/* Search */
.search-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.search-form {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.search-input {
    flex: 1;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a,
.pagination span {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    text-decoration: none;
    color: #374151;
    transition: all 0.2s;
}

.pagination a:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.pagination .current {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d1fae5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert-error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-info {
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* Welcome Section */
.welcome-section {
    text-align: center;
    padding: 4rem 0;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
}

.welcome-description {
    font-size: 1.25rem;
    color: #64748b;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 550px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-overlay.show .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 1px;
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.3));
}

.modal-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.modal-body {
    text-align: center;
    margin-bottom: 2.5rem;
    color: #64748b;
    line-height: 1.7;
    font-size: 1.1rem;
}

.modal-cost-info {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 16px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border: 1px solid #cbd5e1;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.modal-cost-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06b6d4);
    border-radius: 16px 16px 0 0;
}

.modal-cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    font-size: 1rem;
}

.modal-cost-item:last-child {
    margin-bottom: 0;
    font-weight: 700;
    font-size: 1.125rem;
    color: #1e293b;
    border-top: 2px solid #cbd5e1;
    padding-top: 1rem;
    margin-top: 0.75rem;
}

.modal-cost-item span:first-child {
    font-weight: 500;
    color: #475569;
}

.modal-cost-item span:last-child {
    font-weight: 600;
    color: #1e293b;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.modal-btn {
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 120px;
    position: relative;
    overflow: hidden;
    transform: translateY(0);
}

.modal-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.modal-btn:hover::before {
    left: 100%;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.modal-btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px 0 rgba(59, 130, 246, 0.5);
}

.modal-btn-secondary {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #64748b;
    border: 1px solid #cbd5e1;
}

.modal-btn-secondary:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#balance-info {
    background: linear-gradient(135deg, #fefefe 0%, #f8fafc 100%);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1.5rem 0;
    border: 1px solid #e2e8f0;
}

.insufficient-tokens {
    color: #dc2626;
    font-weight: 700;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

.sufficient-tokens {
    color: #059669;
    font-weight: 700;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #bbf7d0;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-title {
        font-size: 2rem;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .table-container {
        font-size: 0.875rem;
    }

    .welcome-title {
        font-size: 2rem;
    }

    .card-content {
        padding: 1rem;
    }
}

/* Responsive Modal */
@media (max-width: 640px) {
    .modal {
        margin: 1rem;
        max-width: none;
        width: calc(100% - 2rem);
        padding: 2rem 1.5rem;
        border-radius: 16px;
    }

    .modal-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .modal-btn {
        width: 100%;
        padding: 1rem;
    }

    .modal-icon {
        font-size: 3rem;
    }

    .modal-title {
        font-size: 1.5rem;
    }
}

/* Loading state for buttons */
.modal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    background: #9ca3af !important;
    color: #ffffff !important;
}

.modal-btn:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

.modal-btn:disabled::before {
    display: none;
}

/* Animation for modal appearance */
@keyframes modalSlideIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalBackdropFadeIn {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

.modal-overlay.show {
    animation: modalBackdropFadeIn 0.3s ease-out;
}

.modal-overlay.show .modal {
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Close button */
.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #1e293b;
    transform: scale(1.1);
}

/* RTL Support */
html[dir="rtl"] {
    direction: rtl;
}

html[dir="rtl"] .nav-links {
    direction: rtl;
}

html[dir="rtl"] .search-form {
    direction: rtl;
}

html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: right;
}