:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --secondary-color: #06b6d4;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    
    --border-color: #e5e7eb;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
}

/* Login Page Specific */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 48px;
    width: 100%;
    max-width: 450px;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    font-weight: bold;
}

.login-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Form Elements */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-input,
.form-select,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--text-light);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

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

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

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

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

button[type="submit"] {
    width: 100%;
}

/* Alert Messages */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 24px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Dashboard/Content Pages */
.dashboard-body {
    background: var(--bg-secondary);
    min-height: 100vh;
}

.navbar {
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.navbar-menu {
    display: flex;
    gap: 12px;
    align-items: center;
}

.navbar-link {
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    font-size: 14px;
}

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

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

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

.navbar-link-danger:hover {
    background: var(--danger-hover);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 16px;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
}

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

.card-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg-tertiary);
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Tables */
.table-container {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

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

/* Table column widths */
table th:nth-child(1), /* Short Code */
table td:nth-child(1) {
    width: 10%;
    min-width: 100px;
}

table th:nth-child(2), /* Short URL */
table td:nth-child(2) {
    width: 18%;
    min-width: 150px;
}

table th:nth-child(3), /* Original URL */
table td:nth-child(3) {
    width: 22%;
    min-width: 180px;
    max-width: 300px;
}

table th:nth-child(4), /* Creator */
table td:nth-child(4) {
    width: 8%;
    min-width: 70px;
}

table th:nth-child(5), /* Created */
table td:nth-child(5) {
    width: 10%;
    min-width: 90px;
}

table th:nth-child(6), /* Clicks */
table td:nth-child(6) {
    width: 7%;
    min-width: 60px;
}

table th:nth-child(7), /* Tracking */
table td:nth-child(7) {
    width: 10%;
    min-width: 85px;
}

table th:nth-child(8), /* Actions */
table td:nth-child(8) {
    width: 15%;
    min-width: 140px;
}

/* URL cell with overflow handling */
.url-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.url-cell a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Actions column styling */
.stats-mini {
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
}

.action-link {
    white-space: nowrap;
}

thead {
    background: var(--bg-tertiary);
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

td {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: var(--bg-secondary);
}

/* Links */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.action-link {
    font-weight: 500;
    font-size: 14px;
}

.action-link-danger {
    color: var(--danger-color);
}

.action-link-danger:hover {
    color: var(--danger-hover);
}

/* Form inline actions */
.inline-form {
    display: inline-block;
    margin-right: 8px;
}

.form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
}

/* URL display defaults */
.url-mobile {
    display: none;
}

.url-desktop {
    display: inline;
}

/* Responsive */
@media (max-width: 768px) {
    .login-card {
        padding: 24px 16px;
    }
    
    .navbar {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }
    
    .navbar-menu {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .navbar-link {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .container {
        padding: 16px 12px;
    }
    
    .page-title {
        font-size: 22px;
    }
    
    .page-subtitle {
        font-size: 14px;
    }
    
    .page-header {
        margin-bottom: 20px;
    }
    
    .card {
        padding: 12px;
        margin-bottom: 16px;
        border-radius: 8px;
    }
    
    .card-header {
        margin-bottom: 12px;
        padding-bottom: 8px;
    }
    
    .card-title {
        font-size: 16px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 16px;
    }
    
    table {
        min-width: 100%;
        font-size: 12px;
        table-layout: auto; /* Allow natural sizing on mobile */
    }
    
    /* Reset column widths on mobile for better fit */
    table th, table td {
        width: auto !important;
        min-width: 80px !important;
    }
    
    th, td {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    th {
        font-size: 11px;
    }
    
    /* Hide less important columns on mobile */
    th:nth-child(4), /* Creator */
    td:nth-child(4),
    th:nth-child(5), /* Created Date */
    td:nth-child(5),
    th:nth-child(7), /* Tracking */
    td:nth-child(7) {
        display: none;
    }
    
    /* Show/hide URL versions */
    .url-desktop {
        display: none;
    }
    
    .url-mobile {
        display: inline;
    }
    
    /* Tighter search filter bar */
    .search-filter-bar {
        padding: 12px;
        gap: 8px;
        margin-bottom: 16px;
    }
    
    .search-box {
        min-width: 100%;
        flex: auto;
    }
    
    .filter-select {
        width: 100%;
        padding: 8px 12px;
    }
    
    .action-buttons {
        width: 100%;
        justify-content: space-between;
    }
    
    .icon-btn {
        padding: 8px 10px;
        font-size: 12px;
        flex: 1;
    }
    
    /* Compact buttons */
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    /* Charts on mobile */
    .card > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    /* Copy dropdown on mobile */
    .copy-dropdown-menu {
        min-width: 200px;
        left: auto;
        right: 0;
    }
    
    /* Stats mini on mobile */
    .stats-mini {
        gap: 4px;
        font-size: 12px;
        flex-wrap: wrap;
    }
    
    /* Result count */
    .result-count {
        font-size: 13px;
        padding: 6px 0;
    }
    
    /* QR Modal on mobile */
    .qr-modal-content {
        padding: 20px;
        margin: 0 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .navbar-brand {
        font-size: 16px;
    }
    
    .navbar-brand-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    /* Even tighter on very small screens */
    th, td {
        padding: 6px 4px;
        font-size: 11px;
    }
    
    .stat-value {
        font-size: 24px;
    }
}

/* Loading States */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.flex {
    display: flex;
}

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

.gap-2 {
    gap: 16px;
}

/* Shorten Form */
.shorten-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.shorten-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.shorten-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 600px;
}

.url-result {
    background: var(--primary-light);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    margin-top: 24px;
    text-align: center;
}

.url-result-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.url-result-link {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    word-break: break-all;
}