/*
 * Stylesheet cho Hệ thống Link Giới thiệu
 * Version: 2.0
 */

/* Reset và Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #47CBFC;
    --secondary-color: #037BD5;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    
    --border-radius: 10px;
    --border-radius-lg: 15px;
    --border-radius-sm: 5px;
    --border-radius-pill: 25px;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-md: 0 8px 32px rgba(0,0,0,0.1);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.15);
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Container và Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
}

.header h1 {
    color: var(--secondary-color);
    text-align: center;
    margin-bottom: 10px;
    font-size: 2rem;
    font-weight: 700;
}

/* Navigation */
.nav {
    text-align: center;
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.nav a,
.nav-btn {
    background: var(--primary-color);
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border: none;
    border-radius: var(--border-radius-pill);
    transition: all var(--transition-normal);
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.nav a:hover,
.nav-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.nav-btn {
    background: var(--danger-color);
}

.nav-btn:hover {
    background: #c82333;
}

/* Cards và Components */
.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius-lg);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    transition: transform var(--transition-normal);
}

.card:hover {
    transform: translateY(-2px);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: border-color var(--transition-normal);
    font-family: inherit;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(71, 203, 252, 0.1);
}

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

.form-group small {
    display: block;
    margin-top: 4px;
    color: #6c757d;
    font-size: 12px;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

/* Buttons */
.btn {
    background: var(--primary-color);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: var(--border-radius-pill);
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all var(--transition-normal);
    text-decoration: none;
    display: inline-block;
    font-family: inherit;
    text-align: center;
    min-width: 120px;
}

.btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: var(--danger-color);
}

.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: var(--warning-color);
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-info {
    background: var(--info-color);
}

.btn-info:hover {
    background: #138496;
}

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-sm {
    padding: 8px 15px;
    font-size: 14px;
    min-width: 80px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 18px;
    min-width: 150px;
}

.btn-block {
    width: 100%;
    display: block;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.product-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.product-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

.product-info {
    padding: 20px;
}

.product-title {
    color: var(--secondary-color);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.4;
}

.product-description {
    color: #666;
    margin-bottom: 15px;
    line-height: 1.5;
    font-size: 14px;
}

.commission-info {
    background: var(--light-color);
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    text-align: center;
    border: 1px solid #dee2e6;
}

.commission-info strong {
    color: var(--success-color);
    font-size: 16px;
}

.product-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Link Display */
.link-display {
    background: var(--light-color);
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    word-break: break-all;
    position: relative;
    font-size: 13px;
    line-height: 1.4;
}

.copy-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    margin-left: 10px;
    transition: background-color var(--transition-fast);
}

.copy-btn:hover {
    background: #218838;
}

/* QR Code */
.qr-code {
    text-align: center;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid #dee2e6;
}

.qr-code canvas {
    border-radius: var(--border-radius-sm);
}

/* Messages */
.message {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
    border-left: 4px solid var(--success-color);
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
    border-left: 4px solid var(--danger-color);
}

.warning-message {
    background: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid #ffeaa7;
    border-left: 4px solid var(--warning-color);
}

.info-message {
    background: #d1ecf1;
    color: #0c5460;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid #bee5eb;
    border-left: 4px solid var(--info-color);
}

/* Login Form */
.login-form {
    max-width: 400px;
    margin: 50px auto;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.login-form h2 {
    text-align: center;
    color: var(--secondary-color);
    margin-bottom: 30px;
    font-weight: 700;
}

/* Zalo Input */
.zalo-input {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius-lg);
    padding: 25px;
    margin-bottom: 30px;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
}

.zalo-input h2 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-weight: 600;
}

.zalo-input input {
    width: 100%;
    max-width: 900px; /* Tăng giới hạn tối đa */
    margin: 0 auto 15px;
    padding: 15px;
    font-size: 16px;
    border: 2px solid var(--primary-color);
    box-sizing: border-box; /* Đảm bảo padding không làm tăng kích thước */
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e1e5e9;
}

table th {
    background: var(--light-color);
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tr:hover {
    background: #f8f9fa;
}

table tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    padding: 4px 8px;
    border-radius: var(--border-radius-pill);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

/* Debug Tools */
details {
    margin-top: 15px;
}

summary {
    cursor: pointer;
    color: var(--secondary-color);
    font-weight: 500;
    padding: 8px 0;
    transition: color var(--transition-fast);
}

summary:hover {
    color: var(--primary-color);
}

details[open] summary {
    margin-bottom: 10px;
}

.debug-panel {
    margin-top: 10px;
    padding: 15px;
    background: var(--light-color);
    border-radius: var(--border-radius);
    border: 1px solid #dee2e6;
}

/* Loading States */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-in {
    animation: slideIn 0.3s ease;
}

.pulse {
    animation: pulse 2s infinite;
}

/* Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--secondary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-info { color: var(--info-color); }
.text-muted { color: #6c757d; }

.bg-primary { background-color: var(--primary-color); }
.bg-secondary { background-color: var(--secondary-color); }
.bg-light { background-color: var(--light-color); }

.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

/* Responsive Design */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .nav {
        flex-direction: column;
        gap: 8px;
    }
    
    .nav a,
    .nav-btn {
        width: 100%;
        text-align: center;
    }
    
    .form-grid,
    .form-grid-3 {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .product-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .product-actions {
        flex-direction: column;
    }
    
    .login-form {
        margin: 20px auto;
        padding: 25px;
    }
    
    .card {
        padding: 20px;
    }
    
    table {
        font-size: 14px;
    }
    
    table th,
    table td {
        padding: 8px;
    }
    
    /* Make tables horizontally scrollable on mobile */
    .table-responsive {
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 15px;
    }
    
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .product-info {
        padding: 15px;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .qr-code canvas {
        image-rendering: pixelated;
    }
}

/* Dark Mode Support (Future Enhancement) */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #ffffff;
        --bg-color: #1a1a1a;
        --card-bg: rgba(255, 255, 255, 0.1);
    }
    
    /* Dark mode styles would go here */
}

/* Print Styles */
@media print {
    .nav,
    .btn,
    .debug-panel {
        display: none !important;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .product-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Focus States for Accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}