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

:root {
    --primary-color: #0066cc;
    --primary-hover: #0052a3;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-color: #ddd;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-size: 1.2rem;
    color: #666;
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 40px;
}

/* Header */
.header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 20px 0;
    margin-bottom: 30px;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
}

.header nav a {
    margin-left: 20px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.header nav a:hover {
    text-decoration: underline;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

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

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

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

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

.btn-small {
    padding: 5px 10px;
    font-size: 0.9rem;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background: var(--bg-color);
    font-weight: 600;
}

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

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card h3 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-card p {
    color: #666;
}

/* Messages */
.message {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Top Links Stats */
.top-links {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.top-link-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.top-link-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-link-header .rank {
    font-size: 1.2rem;
    font-weight: bold;
    color: #667eea;
    min-width: 40px;
}

.top-link-header .slug {
    font-weight: 600;
    color: #667eea;
    text-decoration: none;
    font-size: 1rem;
}

.top-link-header .slug:hover {
    text-decoration: underline;
}

.top-link-header .clicks {
    margin-left: auto;
    font-weight: 600;
    color: #333;
}

.top-link-bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.top-link-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.top-link-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
    color: #666;
}

.top-link-details .title {
    font-weight: 500;
    color: #333;
}

.top-link-details .url {
    color: #666;
    text-decoration: none;
    word-break: break-all;
}

.top-link-details .url:hover {
    color: #667eea;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
}

.stats-summary-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.clicks-table-wrapper {
    overflow-x: auto;
    margin-top: 15px;
}

.clicks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.clicks-table th {
    background: #f5f5f5;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}

.clicks-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.clicks-table tbody tr:hover {
    background: #f9f9f9;
}

.clicks-table code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85rem;
}

.text-muted {
    color: #666;
    font-size: 0.9rem;
    text-align: center;
    margin-top: 15px;
}

.message-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* 404 Page */
.not-found {
    text-align: center;
    padding: 60px 20px;
}

.not-found h1 {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.not-found p {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 20px;
}

/* Share Page */
.share-info {
    max-width: 600px;
    margin: 0 auto;
}

.share-qr {
    text-align: center;
    margin: 30px 0;
}

.share-qr canvas {
    max-width: 300px;
    height: auto;
}

.share-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* Admin Actions */
.action-buttons {
    display: flex;
    gap: 10px;
}

/* Export/Import */
.import-export {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

/* Admin Layout */
.admin-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    margin-top: 20px;
}

.admin-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Stats Summary (Compact) */
.stats-summary {
    display: flex;
    gap: 10px;
    padding: 15px !important;
}

.stat-item {
    flex: 1;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    color: #666;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Import/Export Vertical */
.import-export-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-block {
    width: 100%;
}

/* Sidebar Card Adjustments */
.admin-sidebar .card h3 {
    font-size: 1rem;
    margin-bottom: 15px;
}

.admin-sidebar .card h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

/* Search Box */
.search-box {
    position: relative;
}

.search-box input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 300px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
}

/* Table Enhancements */
table th {
    user-select: none;
}

table th[onclick] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transition: opacity 0.2s;
}

table th[onclick]:hover {
    opacity: 0.9;
}

table tbody tr {
    transition: background-color 0.2s;
}

table tbody tr:hover {
    background-color: #f8f9ff;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
    }

    .header nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .header nav a {
        margin: 0 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table-wrapper {
        overflow-x: auto;
    }
}
