:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --background-color: #f3f4f6;
    --card-background: #ffffff;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.5;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

/* Header */
/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 700;
    font-size: 1.25rem;
}

.brand:hover {
    opacity: 0.8;
}

.brand-icon {
    margin-right: 0.5rem;
    font-size: 1.5rem;
}

/* User Navigation */
.user-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.nav-link .icon {
    margin-right: 0.25rem;
}

.user-capsule {
    display: flex;
    align-items: center;
    background: white;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border-radius: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.5rem;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    margin-right: 0.75rem;
    color: var(--text-color);
}

.divider {
    width: 1px;
    height: 16px;
    background-color: var(--border-color);
    margin-right: 0.5rem;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
}

.btn-logout:hover {
    color: var(--error-color);
    background-color: rgba(239, 68, 68, 0.1);
}

.text-center {
    text-align: center;
}

.header-title-area {
    margin-bottom: 30px;
}

.page-title {
    margin: 0;
    font-size: 2rem;
}

.page-subtitle {
    color: var(--text-muted);
}

/* Google Button */
.btn-google {
    display: inline-flex;
    align-items: center;
    background-color: white;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: 4px;
    padding: 0 12px 0 0;
    text-decoration: none;
    font-family: 'Google Sans', arial, sans-serif;
    font-weight: 500;
    font-size: 14px;
    height: 40px;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-google:hover {
    background-color: #f8faff;
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3);
    border-color: #d2e3fc;
}

.google-icon-wrapper {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.google-icon {
    width: 18px;
    height: 18px;
}

.btn-text {
    padding: 0 8px;
}

/* Tabs */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: -1px;
    /* Overlap with card border if needed, or just sit on top */
    padding-left: 1rem;
    position: relative;
    z-index: 1;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 12px 12px 0 0;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-tab:hover {
    background-color: rgba(255, 255, 255, 0.8);
    color: var(--primary-color);
}

.nav-tab.active {
    background-color: var(--card-background);
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Cards */
.card {
    background: var(--card-background);
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.main-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.main-input-field,
input[type="url"],
input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.main-input-field:focus,
input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Buttons */
.shrink-button,
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.shrink-button:hover,
.btn-primary:hover {
    background-color: var(--primary-hover);
}

.shrink-button:active,
.btn-primary:active {
    transform: translateY(1px);
}

.btn-delete {
    background-color: var(--error-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-delete:hover {
    opacity: 0.9;
}

/* Optional Settings */
.optional-settings {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.optional-settings summary {
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 1rem;
    user-select: none;
}

.optional-fields-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.input-with-prefix,
.input-container-with-button {
    position: relative;
    display: flex;
    align-items: center;
}

.prefix {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-prefix input {
    padding-left: calc(var(--prefix-width, 3rem) + 1rem);
    /* Dynamic padding would be better with JS, but fixed for now */
}

#custom_code {
    padding-left: 8rem;
    /* Approximate for 'durl.uk/' */
}

.password-icon {
    left: 0.75rem;
}

.password-input-group input {
    padding-left: 2.5rem;
}

.suffix-btn {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
}

/* Edit Code Input Group */
.edit-code-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.edit-code-input-group input {
    padding-right: 100px;
    /* Default for desktop */
}

.edit-code-input-group .btn-verify {
    position: absolute;
    right: 5px;
    top: 5px;
    bottom: 5px;
    padding: 0 20px;
}

@media (max-width: 640px) {
    .edit-code-input-group {
        flex-direction: column;
        gap: 10px;
    }

    .edit-code-input-group input {
        padding-right: 1rem;
        /* Reset padding */
        width: 100%;
    }

    .edit-code-input-group .btn-verify {
        position: static;
        /* Stack below input */
        width: 100%;
        padding: 10px;
    }
}

/* Feedback */
.feedback {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.feedback.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

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

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

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th,
td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

th {
    background-color: #f9fafb;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    font-size: 0.9375rem;
}

.center {
    text-align: center;
}

.url-cell {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.url-cell a {
    text-decoration: none;
    color: inherit;
}

table a {
    text-decoration: none;
}

table a:hover {
    text-decoration: none;
}

@media (max-width: 640px) {
    .url-cell {
        max-width: 150px;
    }
}

/* Footer */
.main-footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: auto;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 0.5rem;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 10px;
    }

    .card {
        padding: 1.5rem;
    }

    .optional-fields-group {
        grid-template-columns: 1fr;
    }

    .main-input-group {
        flex-direction: column;
    }

    .shrink-button {
        width: 100%;
        justify-content: center;
    }

    .main-header {
        flex-direction: row;
        /* Keep row direction on mobile */
        justify-content: space-between;
        align-items: center;
        padding: 1rem 0;
        gap: 0.5rem;
    }

    .header-actions {
        /* width: 100%; Removed to allow right alignment */
        display: flex;
        justify-content: flex-end;
        /* Align to right */
        gap: 0.5rem;
    }

    /* Optimize Google Button for Mobile */
    .btn-google {
        padding: 0;
        width: 40px;
        justify-content: center;
    }

    .btn-google .btn-text {
        display: none;
    }

    /* Optimize Nav Links (Stats) for Mobile */
    .nav-link .text {
        display: none;
    }

    .nav-link .icon {
        margin-right: 0;
    }

    .user-nav {
        width: 100%;
        justify-content: space-between;
        /* flex-wrap: wrap; User requested NO wrap */
        gap: 0.5rem;
    }

    .brand {
        font-size: 1.5rem;
    }

    /* Hide username on mobile */
    .user-name {
        display: none;
    }

    .user-capsule {
        padding: 0.25rem;
        /* Reduce padding since name is hidden */
    }

    .user-avatar {
        margin-right: 0;
        /* Remove margin since name is hidden */
    }

    .divider {
        display: none;
        /* Hide divider too */
    }

    /* Prevent overflow */
    body,
    html {
        overflow-x: hidden;
        width: 100%;
    }

    /* Mobile Tabs - Horizontal Scroll */
    .nav-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
        /* Space for scrollbar if visible */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Firefox */
        margin-left: -10px;
        /* Counteract container padding */
        margin-right: -10px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari */
    }

    .nav-tab {
        padding: 10px 16px;
        font-size: 0.9rem;
        flex-shrink: 0;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .header-title-area {
        margin-bottom: 20px;
    }

    .upload-drop-zone {
        padding: 1.5rem 1rem;
    }

    /* Optimize Table for Mobile */
    th,
    td {
        padding: 0.5rem 0.25rem;
        font-size: 0.85rem;
    }

    /* Prevent wrapping for Short Code and Actions */
    td:first-child,
    td:last-child,
    th:first-child,
    th:last-child {
        white-space: nowrap;
    }

    .url-cell {
        max-width: 80px;
        /* Force truncation on very small screens */
    }

    /* Compact Action Buttons */
    td .btn-primary,
    td .btn-delete {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        margin: 0 2px;
    }
}

/* API Docs & Code Blocks */
pre {
    background-color: #1e293b;
    /* Dark slate */
    color: #e2e8f0;
    /* Light gray text */
    padding: 1.5rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 1rem 0 2rem 0;
    border: 1px solid #334155;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
    color: #d946ef;
    /* Pinkish for inline code */
}

pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
    border-radius: 0;
}

.endpoint {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-family: monospace;
}

.method {
    background-color: #10b981;
    /* Green */
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: bold;
    font-size: 0.8rem;
    font-weight: bold;
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Upload Area */
.upload-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #f9fafb;
    margin-bottom: 1.5rem;
    position: relative;
}

.upload-drop-zone:hover,
.upload-drop-zone.dragover {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.5;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* File Preview */
.file-preview-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    margin-top: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.file-name {
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.cancel-upload-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
    line-height: 1;
    margin-left: auto;
}

.cancel-upload-btn:hover {
    color: var(--error-color);
}

/* Progress Bar */
.progress-container {
    height: 6px;
    background-color: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    width: 0;
    transition: width 0.2s ease;
}

/* Success Result Styles */
.link-result-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f3f4f6;
    padding: 10px 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.short-link-highlight {
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.1rem;
    flex: 1;
    word-break: break-all;
}

.short-link-highlight:hover {
    text-decoration: none;
}

.copy-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

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

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

.edit-code-box {
    background: #fffbeb;
    /* Amber-50 */
    border: 1px solid #fcd34d;
    /* Amber-300 */
    color: #92400e;
    /* Amber-800 */
    padding: 10px 15px;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.edit-code-box code {
    background: rgba(255, 255, 255, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-family: monospace;
    font-size: 1.1em;
}

/* Admin Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 5px 0;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.setting-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.setting-card h3 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    font-size: 1.1rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
    vertical-align: middle;
    margin-right: 10px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(16px);
}

.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-header h1 {
    margin: 0;
}

.admin-search-form {
    display: flex;
    gap: 10px;
    max-width: 300px;
    flex-grow: 1;
}

.admin-search-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    flex-grow: 1;
    font-size: 0.9rem;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.page-link {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
}

.page-link.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.badge {
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.75em;
    font-weight: bold;
}

.badge-tg {
    background: #e3f2fd;
    color: #0288d1;
}

.badge-pwd {
    background: #fff3cd;
    color: #856404;
}

.action-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
}

@media (max-width: 640px) {
    .admin-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-search-form {
        max-width: 100%;
    }

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