/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(to bottom, #dbeafe, #ffffff);
    min-height: 100vh;
    color: #374151;
    line-height: 1.5;
    padding-top: calc((var(--tg-content-safe-area-inset-top) + var(--tg-safe-area-inset-top))*2);
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    position: fixed;
    width: 90%;
    border-radius: 12px;
    opacity: 0.95;
    left: 5%;
    right: 5%;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.05),
    0 2px 6px rgba(0, 0, 0, 0.1);
    top: calc(var(--tg-content-safe-area-inset-top) + var(--tg-safe-area-inset-top));
    z-index: 100;
}

.header-content {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    color: #111827;
}

.profile-btn {
    background: none;
    border: none;
}

.profile-btn:hover {
    background: #f3f4f6;
}

/* Main Content */
.main-content {
    padding: 24px 16px;
    max-width: 480px;
    margin: 0 auto;
}

/* Welcome Section */
.welcome-section {
    text-align: center;
    margin-bottom: 24px;
}

.welcome-section h2 {
    font-size: 24px;
    font-weight: bold;
    color: #111827;
    margin-bottom: 8px;
}

.welcome-section p {
    color: #6b7280;
    font-size: 14px;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-header {
    padding: 16px 16px 12px;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 i {
    color: #3b82f6;
}

.card-header p {
    font-size: 14px;
    color: #6b7280;
}

.card-content {
    padding: 0 16px 16px;
}

/* Address Fields */
.address-fields {
    margin-bottom: 16px;
}

.address-field {
    margin-bottom: 16px;
}

.address-field label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.address-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
    font-family: monospace;
    font-size: 14px;
    color: #374151;
}

.copy-btn {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}

.copy-btn:hover {
    background: #f3f4f6;
}

.copy-btn.copied {
    color: #10b981;
    border-color: #10b981;
}

/* Buttons */
.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: white;
    color: #3b82f6;
    border: 1px solid #3b82f6;
}

.btn-secondary:hover {
    background: #3b82f6;
    color: white;
}

.btn-outline {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-outline:hover {
    background: #f3f4f6;
}

.full-width {
    width: 100%;
}

/* Info Box */
.info-box {
    background: #dbeafe;
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    color: #1e40af;
    margin-top: 16px;
}

/* Section */
.section {
    margin-bottom: 24px;
}

.section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 12px;
}

/* Action Cards */
.action-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.action-card:hover {
    background: #f9fafb;
}

.action-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.action-icon.blue {
    background: #dbeafe;
    color: #3b82f6;
}

.action-icon.green {
    background: #d1fae5;
    color: #10b981;
}

.action-icon.purple {
    background: #e9d5ff;
    color: #8b5cf6;
}

.action-content h4 {
    font-size: 16px;
    font-weight: 500;
    color: #111827;
    margin-bottom: 2px;
}

.action-content p {
    font-size: 14px;
    color: #6b7280;
}

/* CTA Card */
.cta-card {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.cta-card .card-content {
    padding: 16px;
}

.cta-card h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.cta-card p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 16px;
}

.text-center {
    text-align: center;
}

/* Back Button */
.back-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #6b7280;
    transition: background-color 0.2s;
}

.back-btn:hover {
    background: #f3f4f6;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

/* Tab Buttons */
.tab-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.tab-btn:hover:not(.active) {
    background: #f3f4f6;
}

/* Order Cards */
.order-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s;
}

.order-card:hover {
    background: #f9fafb;
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.order-id {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
}

.order-id i {
    color: #6b7280;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.in-transit {
    background: #dbeafe;
    color: #1e40af;
}

.status-badge.delivered {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.ready {
    background: #fed7aa;
    color: #9a3412;
}

.status-badge.received {
    background: #f0fdf4;
    color: #15803d;
}

.status-badge.created {
    background: #e0e7ff;
    color: #3730a3;
}

.order-description {
    font-size: 14px;
    color: #374151;
    margin-bottom: 8px;
}

.order-location {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #6b7280;
}

/* Expandable Order Details */
.expand-btn {
    width: 100%;
    padding: 8px;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.expand-btn:hover {
    background: #f3f4f6;
}

.order-stages {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.stage {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.stage:last-child {
    margin-bottom: 0;
}

.stage-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2px;
}

.stage-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: white;
}

.stage-dot.completed {
    background: #10b981;
    border-color: #10b981;
}

.stage-dot.current {
    background: #3b82f6;
    border-color: #3b82f6;
}

.stage-line {
    width: 2px;
    height: 24px;
    background: #e5e7eb;
    margin-top: 4px;
}

.stage-line.completed {
    background: #d1fae5;
}

.stage-content {
    flex: 1;
    padding-bottom: 8px;
}

.stage-title {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    margin-bottom: 2px;
}

.stage-title.pending {
    color: #6b7280;
}

.stage-location {
    font-size: 12px;
    color: #6b7280;
}

.stage-date {
    font-size: 12px;
    color: #6b7280;
    text-align: right;
}

/* QR Code Styles */
.qr-container {
    text-align: center;
    padding: 24px;
}

.qr-code {
    width: 200px;
    height: 200px;
    background: #f3f4f6;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 14px;
}

.qr-info {
    margin-bottom: 24px;
}

.qr-info p {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 4px;
}

.qr-url {
    font-size: 12px;
    color: #6b7280;
    word-break: break-all;
    padding: 0 16px;
}

.qr-actions {
    display: flex;
    gap: 12px;
}

.qr-actions .btn {
    flex: 1;
}

/* Branch Styles */
.branch-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.branch-header {
    margin-bottom: 12px;
}

.branch-name {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.branch-name i {
    color: #3b82f6;
}

.branch-manager {
    font-size: 14px;
    color: #6b7280;
}

.branch-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.branch-detail {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
}

.branch-detail i {
    color: #6b7280;
    margin-top: 2px;
    width: 16px;
}

.branch-phone {
    color: #3b82f6;
    text-decoration: none;
}

.branch-phone:hover {
    text-decoration: underline;
}

/* Admin Styles */
.admin-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e5e7eb;
    position: fixed;
    width: 90%;
    border-radius: 12px;
    opacity: 0.95;
    left: 5%;
    right: 5%;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.05),
    0 2px 6px rgba(0, 0, 0, 0.1);
    top: calc(var(--tg-content-safe-area-inset-top) + var(--tg-safe-area-inset-top));
    z-index: 100;
}

.admin-header .header-content {
    padding: 12px 16px;
}

.admin-header .logo {
    font-size: 18px;
    color: #111827;
}

.admin-header p {
    font-size: 14px;
    color: #6b7280;
    margin-top: 2px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 4px;
}

.stat-number.blue {
    color: #3b82f6;
}

.stat-number.green {
    color: #10b981;
}

.stat-number.purple {
    color: #8b5cf6;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
}

/* Scanner Styles */
.scanner-area {
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    margin-bottom: 24px;
}

.scanner-icon {
    font-size: 48px;
    color: #6b7280;
    margin-bottom: 16px;
}

.scanner-text {
    color: #6b7280;
    margin-bottom: 8px;
}

.scanner-subtext {
    font-size: 14px;
    color: #6b7280;
}

.scanning .scanner-icon {
    animation: spin 2s linear infinite;
    color: #3b82f6;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Responsive Design */
@media (max-width: 480px) {
    .main-content {
        padding: 16px 12px;
    }

    .card-content {
        padding: 0 12px 12px;
    }

    .action-card {
        padding: 12px;
    }

    .qr-code {
        width: 160px;
        height: 160px;
    }
}

/* Hidden class for JavaScript */
.hidden {
    display: none !important;
}

/* Utility Classes */
.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.p-4 {
    padding: 16px;
}

.text-sm {
    font-size: 14px;
}

.text-xs {
    font-size: 12px;
}

.font-medium {
    font-weight: 500;
}

.font-bold {
    font-weight: bold;
}

.text-gray-500 {
    color: #6b7280;
}

.text-gray-600 {
    color: #4b5563;
}

.text-blue-600 {
    color: #2563eb;
}

.text-green-600 {
    color: #059669;
}

.bg-gray-50 {
    background-color: #f9fafb;
}