/* CSS Variables - Design System */
:root {
    --background: 222 47% 11%;
    --foreground: 210 40% 98%;
    --card: 217 33% 17%;
    --card-foreground: 210 40% 98%;
    --primary: 173 80% 40%;
    --primary-foreground: 222 47% 11%;
    --secondary: 217 33% 25%;
    --secondary-foreground: 210 40% 98%;
    --muted: 217 33% 25%;
    --muted-foreground: 215 20% 65%;
    --accent: 173 80% 40%;
    --accent-foreground: 222 47% 11%;
    --destructive: 0 84% 60%;
    --destructive-foreground: 210 40% 98%;
    --border: 217 33% 30%;
    --input: 217 33% 25%;
    --ring: 173 80% 40%;
    --radius: 0.75rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, hsl(var(--background)) 0%, hsl(222 47% 15%) 50%, hsl(217 33% 17%) 100%);
    color: hsl(var(--foreground));
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeIn 0.6s ease-out;
}

.header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(173 80% 50%) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.header p {
    color: hsl(var(--muted-foreground));
    font-size: 1.1rem;
}

/* Layout */
.main-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

/* Card Base */
.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.5rem;
}

/* Form Section */
.form-section {
    position: sticky;
    top: 2rem;
}

.form-section h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: hsl(var(--foreground));
}

.form-group small {
    display: block;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.25rem;
}

.input, .textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: hsl(var(--input));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.input:focus, .textarea:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsla(var(--ring), 0.2);
}

.input::placeholder, .textarea::placeholder {
    color: hsl(var(--muted-foreground));
}

.textarea {
    min-height: 80px;
    resize: vertical;
}

/* Tags Input */
.tags-input-container {
    display: flex;
    gap: 0.5rem;
}

.tags-input-container .input {
    flex: 1;
}

.tags-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: hsla(var(--primary), 0.2);
    color: hsl(var(--primary));
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tag button:hover {
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: calc(var(--radius) - 2px);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(173 80% 35%) 100%);
    color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px hsla(var(--primary), 0.3);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover {
    background: hsl(217 33% 30%);
}

.btn-ghost {
    background: transparent;
    color: hsl(var(--muted-foreground));
}

.btn-ghost:hover {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.btn-destructive {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover {
    background: hsl(0 84% 55%);
}

.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
}

.btn-full {
    width: 100%;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Content Section */
.content-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-input-wrapper {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-input-wrapper .input {
    padding-left: 2.75rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: hsl(var(--muted-foreground));
    pointer-events: none;
}

.select {
    min-width: 200px;
    padding: 0.75rem 1rem;
    background: hsl(var(--input));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    cursor: pointer;
}

.select:focus {
    outline: none;
    border-color: hsl(var(--ring));
}

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

/* Link Card */
.link-card {
    background: linear-gradient(135deg, hsl(var(--card)) 0%, hsl(217 33% 20%) 100%);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all 0.3s ease;
    animation: scaleIn 0.3s ease-out;
}

.link-card:hover {
    border-color: hsla(var(--primary), 0.5);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px hsla(0 0% 0% / 0.3);
}

.link-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.link-card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0;
}

.link-card-actions {
    display: flex;
    gap: 0.25rem;
}

.link-card-url {
    display: block;
    color: hsl(var(--primary));
    font-size: 0.875rem;
    text-decoration: none;
    word-break: break-all;
    margin-bottom: 0.75rem;
    transition: color 0.2s;
}

.link-card-url:hover {
    color: hsl(173 80% 50%);
    text-decoration: underline;
}

.link-card-category {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: hsl(var(--secondary));
    border-radius: 9999px;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.75rem;
}

.link-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    animation: fadeIn 0.5s ease-out;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: hsla(var(--primary), 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--primary));
}

.empty-state h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: hsl(var(--muted-foreground));
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: hsla(0 0% 0% / 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 90%;
    max-width: 450px;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.modal p {
    color: hsl(var(--muted-foreground));
    margin-bottom: 1.5rem;
}

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

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 10px 25px hsla(0 0% 0% / 0.3);
    animation: slideInRight 0.3s ease-out;
    min-width: 300px;
}

.toast.success {
    border-color: hsl(var(--primary));
}

.toast.error {
    border-color: hsl(var(--destructive));
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid hsl(var(--border));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Stats */
.stats {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.stats-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 0.5rem;
    background: hsla(var(--primary), 0.2);
    color: hsl(var(--primary));
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

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

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .links-grid {
        grid-template-columns: 1fr;
    }
    
    .form-section {
        position: static;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: hsl(var(--background));
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--border));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground));
}
