/* Modern Design Tokens */
:root {
    --bg-primary: #0a0a14;
    --bg-surface: rgba(22, 22, 38, 0.65);
    --bg-surface-hover: rgba(30, 30, 52, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-active: rgba(99, 102, 241, 0.4);
    
    --color-text: #f3f4f6;
    --color-text-muted: #9ca3af;
    
    --primary: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    --accent: #10b981; /* Emerald */
    --accent-hover: #059669;
    --danger: #ef4444; /* Rose/Red */
    --danger-hover: #dc2626;
    --secondary: rgba(255, 255, 255, 0.06);
    --secondary-hover: rgba(255, 255, 255, 0.12);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);

    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Global styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--color-text);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Atmospheric Glow Background */
.glow-bg {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(16, 185, 129, 0.05) 50%, rgba(0, 0, 0, 0) 100%);
    top: -200px;
    right: -100px;
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
}

/* Header */
.app-header {
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 10, 20, 0.8);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.logo-icon i {
    width: 22px;
    height: 22px;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #ffffff, #d1d5db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: white;
}

.btn-primary {
    background-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-accent {
    background-color: var(--accent);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-accent:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background-color: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Main Area */
.app-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Control Bar */
.control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.search-filter {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-grow: 1;
    max-width: 800px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex-grow: 1;
    min-width: 250px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    width: 18px;
    height: 18px;
}

.search-box input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.category-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-tag {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--color-text-muted);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-tag:hover, .filter-tag.active {
    background: rgba(99, 102, 241, 0.12);
    border-color: var(--primary);
    color: var(--color-text);
}

.status-indicator {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dot-separator {
    color: rgba(255, 255, 255, 0.15);
}

/* Links Grid */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Link Card */
.link-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
    backdrop-filter: blur(12px);
    overflow: hidden;
}

.link-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background var(--transition-fast);
}

.link-card.checked {
    border-color: var(--border-color-active);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.1);
}

.link-card.checked::before {
    background: linear-gradient(to right, var(--primary), var(--accent));
}

.link-card:hover {
    transform: translateY(-4px);
    background: var(--bg-surface-hover);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-md);
}

.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-checkbox-wrapper {
    position: relative;
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.card-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    appearance: none;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-checkbox:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.card-checkbox:checked::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
    font-weight: 900;
}

.card-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    overflow: hidden;
}

.card-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-body {
    flex-grow: 1;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-url {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-category {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-muted);
    border: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
}

.card-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.card-btn i,
.card-btn svg {
    pointer-events: none;
}

.card-btn.delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: 1000;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #0f0f20;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.open .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.close-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.form-group input[type="text"],
.form-group input[type="url"] {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Switch styling */
.checkbox-group {
    flex-direction: row;
    align-items: center;
    padding: 0.5rem 0;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.switch-label input {
    display: none;
}

.slider {
    width: 40px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    position: relative;
    transition: background-color var(--transition-fast);
}

.slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: white;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-fast);
}

.switch-label input:checked + .slider {
    background-color: var(--accent);
}

.switch-label input:checked + .slider::before {
    transform: translateX(20px);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    z-index: 2000;
    transition: transform var(--transition-normal);
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: rgba(16, 185, 129, 0.9);
}

/* Admin Button */
.btn-admin-icon {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--color-text-muted);
    padding: 0.625rem;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    position: relative;
}

.btn-admin-icon:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

.btn-admin-icon.admin-active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
    animation: adminPulse 2.5s ease-in-out infinite;
}

.btn-admin-icon.admin-active:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.2);
    animation: none;
}

@keyframes adminPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.35); }
}

/* Admin Actions Container */
.admin-only-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Admin Login Modal */
.admin-login-modal-content {
    max-width: 400px;
    padding: 0;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.admin-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.admin-login-header {
    text-align: center;
    padding: 2.5rem 2rem 1.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(16, 185, 129, 0.08) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.admin-avatar i {
    width: 32px;
    height: 32px;
    color: white;
}

.admin-login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.admin-subtitle {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

/* Admin Login Form */
.admin-login-form {
    padding: 1.75rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.login-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-wrapper .field-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.login-input-wrapper input {
    width: 100%;
    padding: 0.85rem 2.75rem 0.85rem 2.75rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.login-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.login-input-wrapper input:focus ~ .field-icon,
.login-input-wrapper input:focus + .field-icon {
    color: var(--primary);
}

/* Reverse order fix: icon is before input */
.login-input-wrapper:focus-within .field-icon {
    color: var(--primary);
}

.password-toggle {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.password-toggle:hover {
    color: var(--color-text);
}

.password-toggle i {
    width: 18px;
    height: 18px;
}

/* Sign In Button */
.btn-login-submit {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    color: white;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-login-submit:hover {
    background: linear-gradient(135deg, var(--primary-hover), #7c3aed);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

.btn-login-cancel {
    width: 100%;
    padding: 0.65rem;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    background: transparent;
    transition: all var(--transition-fast);
}

.btn-login-cancel:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.04);
}

/* Login Error */
.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.6rem 0.85rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    text-align: center;
}

/* Shake animation for login error */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* Copy button hover */
.card-btn.copy-btn:hover {
    color: var(--accent);
    background: rgba(16, 185, 129, 0.1);
}

/* Confirm Delete Modal */
.confirm-delete-content {
    max-width: 380px;
    padding: 0;
    overflow: hidden;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.confirm-delete-header {
    padding: 2rem 2rem 1.25rem;
}

.confirm-delete-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.confirm-delete-icon i {
    width: 28px;
    height: 28px;
    color: var(--danger);
}

.confirm-delete-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
}

.confirm-delete-text {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.confirm-delete-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem 2rem 1.75rem;
}

.confirm-delete-actions .btn {
    flex: 1;
}

.btn-danger {
    background-color: var(--danger);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

.btn-danger i,
.btn-danger svg {
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .admin-only-actions {
        flex-wrap: wrap;
    }
    
    .header-actions button {
        flex-grow: 1;
    }
    
    .control-bar {
        flex-direction: column;
        align-items: stretch;
    }
}
