/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6366f1;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.25rem;
    opacity: 0.95;
    font-weight: 300;
}

/* ===== Card ===== */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.75rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 600;
}

.card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-link {
    color: var(--primary-color);
    background: none;
    padding: 4px 8px;
    font-size: 0.875rem;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

.icon-link {
    font-size: 1.2rem;
    line-height: 1;
    padding: 2px;
}

.icon-link:hover {
    text-decoration: none;
    opacity: 0.7;
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
    display: inline-block;
}

.btn-secondary:hover {
    background: var(--text-primary);
    transform: translateY(-1px);
}

/* ===== Alerts ===== */
.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-success strong {
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
}

.alert-success a {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
}

.alert-success a:hover {
    text-decoration: underline;
}

/* URL Copy Container */
.url-copy-container {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.url-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #86efac;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
}

.url-input:focus {
    outline: none;
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-copy:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-copy:active {
    transform: translateY(0);
}

#copyIcon {
    font-size: 1.1rem;
}

.success-links {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 0.9rem;
}

.success-links .separator {
    color: #86efac;
}

/* ===== Auth Info ===== */
.auth-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    margin-bottom: 24px;
    color: #166534;
    font-size: 0.875rem;
}

.badge-admin {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
    text-transform: uppercase;
}

/* ===== Stats ===== */
.stats {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.stats strong {
    font-weight: 600;
    font-size: 1.3rem;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 24px;
}

.stat-item {
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 1.125rem;
    color: var(--text-primary);
    font-weight: 600;
}

.stat-value a {
    color: var(--primary-color);
    text-decoration: none;
}

.stat-value a:hover {
    text-decoration: underline;
}

.stat-url {
    word-break: break-all;
    font-size: 0.95rem;
    font-weight: 400;
}

.stat-number {
    font-size: 2rem;
    color: var(--primary-color);
}

/* ===== Actions ===== */
.actions {
    margin-top: 24px;
    text-align: center;
}

/* ===== Error Card ===== */
.error-card {
    text-align: center;
}

.error-card h1 {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.error-card p {
    margin-bottom: 24px;
    color: var(--text-secondary);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    color: white;
    font-size: 0.875rem;
    opacity: 0.9;
}

/* ===== reCAPTCHA ===== */
.g-recaptcha {
    margin-bottom: 20px;
}

/* ===== Additional Elements ===== */
.card-subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.form-hint {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.info-box {
    margin-top: 20px;
    padding: 12px 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1e40af;
    font-size: 0.9rem;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .card {
        padding: 20px;
        border-radius: 12px;
    }
    
    .card h2 {
        font-size: 1.5rem;
    }
    
    .form-group input {
        font-size: 16px; /* Évite le zoom sur iOS */
    }
    
    .btn {
        padding: 14px 20px;
    }
    
    .url-copy-container {
        flex-direction: column;
    }
    
    .btn-copy {
        justify-content: center;
    }
    
    .success-links {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .success-links .separator {
        display: none;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.75rem;
    }
    
    .card {
        padding: 16px;
    }
    
    .auth-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease;
}

/* ===== Loading State ===== */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== Focus Visible ===== */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== Stats Overview ===== */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.stat-card-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ===== URL List ===== */
.urls-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.url-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.url-list-item:hover {
    border-color: var(--primary-color);
    background: white;
    box-shadow: var(--shadow);
}

.url-list-main {
    flex: 1;
    min-width: 0;
}

.url-list-short {
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: var(--primary-color);
}

.url-list-target {
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.url-list-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.url-list-stats {
    margin-left: 16px;
}

.url-stat-badge {
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
    min-width: 70px;
}

.url-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.url-stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stats-grid .card {
    margin-bottom: 0;
}

.stats-grid h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.stat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--background);
    border-radius: 6px;
}

.stat-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===== URL Header ===== */
.url-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.url-info {
    flex: 1;
    min-width: 0;
}

.url-short {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.url-short a {
    color: var(--primary-color);
    text-decoration: none;
}

.url-short a:hover {
    text-decoration: underline;
}

.url-target {
    font-size: 0.95rem;
    color: var(--text-secondary);
    word-break: break-all;
}

/* ===== Clicks Table ===== */
.clicks-table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
}

.clicks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.clicks-table th {
    background: var(--background);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.clicks-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.clicks-table tr:hover {
    background: var(--background);
}

.clicks-table code {
    background: var(--background);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
}

.referer-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.referer-cell a {
    color: var(--primary-color);
    text-decoration: none;
}

.referer-cell a:hover {
    text-decoration: underline;
}

.text-muted {
    color: var(--text-secondary);
}

.text-center {
    text-align: center;
}

/* ===== Creator Info ===== */
.creator-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.creator-item {
    padding: 12px;
    background: var(--background);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.creator-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.creator-item code {
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    border: 1px solid var(--border-color);
}

.creator-item span:not(.creator-label) {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ===== Card Header Row ===== */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header-row h2 {
    margin-bottom: 0;
}

.toggle-link {
    font-size: 0.9rem;
    color: var(--primary-color);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toggle-link:hover {
    background: var(--background);
    text-decoration: none;
}

/* ===== Responsive Stats ===== */
@media (max-width: 768px) {
    .stats-overview {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .url-list-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .url-list-stats {
        margin-left: 0;
        margin-top: 12px;
        width: 100%;
    }
    
    .url-stat-badge {
        width: 100%;
    }
    
    .url-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .clicks-table {
        font-size: 0.8rem;
    }
    
    .clicks-table th,
    .clicks-table td {
        padding: 8px;
    }
}
