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

:root {
    /* Dark Theme Colors */
    --bg-primary: hsl(220, 15%, 8%);
    --bg-secondary: hsl(220, 15%, 12%);
    --bg-muted: hsl(220, 15%, 18%);
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.1);
    
    /* Accent Colors */
    --primary-red: hsl(355, 78%, 56%);
    --primary-red-hover: hsl(355, 78%, 48%);
    --destructive: hsl(0, 84%, 60%);
    
    /* Text Colors */
    --text-primary: hsl(0, 0%, 98%);
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.7);
    
    /* Borders */
    --border-color: rgba(255, 255, 255, 0.15);
    --border-color-light: rgba(255, 255, 255, 0.1);
    
    /* Shadows */
    --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.3);
    --shadow-card-inner: inset 0 1px 1px rgba(255, 255, 255, 0.1);
    --shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.header-logo {
    height: 80px;
    width: auto;
    max-width: 300px;
    object-fit: contain;
    flex-shrink: 0;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-blue-dark);
    letter-spacing: -0.02em;
}

/* Add Button */
.btn-add {
    width: 44px;
    height: 44px;
    border-radius: 0.5rem;
    background: var(--primary-blue);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.btn-add:hover {
    background: var(--primary-blue-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* Main Content */
.main-content {
    padding: 2rem 1.5rem;
    flex: 1;
    min-height: calc(100vh - 140px);
}

.content-container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.content-container > * {
    text-align: left;
}

.content-container > .page-title {
    text-align: center !important;
}

.page-title {
    font-size: 2rem;
    font-weight: 600;
    color: white;
    margin: 0 auto 2rem auto;
    letter-spacing: -0.02em;
    text-align: center !important;
    display: block;
    width: 100%;
}

/* Applications Grid */
.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Application Card - Glassmorphic */
.app-card {
    background: var(--bg-card);
    backdrop-filter: blur(48px);
    -webkit-backdrop-filter: blur(48px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-card), var(--shadow-card-inner);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
}

.app-card:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-card-hover), var(--shadow-card-inner);
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
}

.app-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.app-card-content {
    flex: 1;
    min-width: 0;
    padding-right: 4rem; /* Make room for icon */
}

.app-card-icon {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
}

.app-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.375rem;
    object-fit: cover;
    background: var(--bg-gray-100);
    flex-shrink: 0;
    border: 1px solid var(--border-color-light);
}

.app-icon-svg {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    border: 1px solid var(--border-color-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-red);
}

.app-icon-svg svg {
    width: 32px;
    height: 32px;
}

.app-icon-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-red-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.app-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    word-break: break-word;
}

.app-url {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    opacity: 0.8;
    word-break: break-all;
    overflow-wrap: break-word;
}

.app-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
    opacity: 0.7;
}

.app-card-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.app-card-actions button {
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.app-card:hover .app-card-actions button {
    opacity: 1;
}

.app-card-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
}

.app-card-actions button:last-child:hover {
    background: rgba(220, 38, 38, 0.2);
    border-color: var(--destructive);
    color: var(--destructive);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    backdrop-filter: blur(48px);
    -webkit-backdrop-filter: blur(48px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    color: var(--text-muted);
    box-shadow: var(--shadow-card), var(--shadow-card-inner);
}

.empty-state svg {
    margin-bottom: 1rem;
    color: var(--text-light);
}

.empty-state p {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Footer */
.site-footer {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(64px);
    -webkit-backdrop-filter: blur(64px);
    border-top: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.footer-logo {
    height: 60px;
    width: auto;
    max-width: 300px;
    object-fit: contain;
    flex-shrink: 0;
}

.footer-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
}

.btn-logout svg {
    width: 16px;
    height: 16px;
}

.btn-settings {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-settings:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
}

.btn-settings svg {
    width: 16px;
    height: 16px;
}

.btn-add-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary-blue);
    border: none;
    border-radius: 0.375rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    box-shadow: var(--shadow-sm);
}

.btn-add-footer:hover {
    background: var(--primary-blue-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-add-footer svg {
    width: 16px;
    height: 16px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-container {
    background: var(--bg-card);
    backdrop-filter: blur(64px);
    -webkit-backdrop-filter: blur(64px);
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-card), var(--shadow-card-inner);
    border: 1px solid var(--border-color);
}

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

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.btn-close {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
}

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

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

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--bg-input);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
    background: rgba(255, 255, 255, 0.15);
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.error-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

.error-message.show {
    display: block;
}

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

/* Buttons */
.btn-primary {
    background: var(--primary-red);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

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

/* Icon Picker Styles */
.icon-picker-container {
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 1rem;
    background: var(--bg-gray-50);
}

.icon-picker-selected {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.icon-preview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: var(--primary-red);
    flex-shrink: 0;
}

.icon-preview svg {
    width: 24px;
    height: 24px;
}

.icon-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.icon-color-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.color-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.color-input {
    width: 48px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    background: var(--bg-white);
    transition: all 0.2s ease;
}

.color-input:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input::-webkit-color-swatch {
    border: none;
    border-radius: 0.25rem;
}

.color-input::-moz-color-swatch {
    border: none;
    border-radius: 0.25rem;
}

.btn-clear-icon {
    padding: 0.375rem 0.75rem;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-icon:hover {
    background: var(--bg-gray-50);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.icon-picker-search {
    margin-bottom: 1rem;
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    min-height: 200px;
}

/* Ensure grid shows all icons */
.icon-picker-grid:empty::before {
    content: 'Loading icons...';
    display: block;
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.icon-picker-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-picker-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-red);
    color: var(--primary-red);
    transform: translateY(-1px);
}

.icon-picker-btn.selected {
    background: var(--primary-red);
    border-color: var(--primary-red);
    color: white;
}

.icon-picker-btn.selected:hover {
    background: var(--primary-red-hover);
    border-color: var(--primary-red-hover);
}

.icon-picker-btn svg {
    width: 24px;
    height: 24px;
}

/* Login Modal Specific */
#loginModal .modal-container {
    max-width: 400px;
}

/* Settings Modal Styles */
.background-preview-container {
    position: relative;
    width: 100%;
    height: 192px;
    border-radius: 0.375rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-gray-100);
}

.background-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.background-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0);
    pointer-events: none;
}

.background-preview-overlay span {
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.btn-remove-background {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    color: #dc2626;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.btn-remove-background:hover {
    background: white;
    border-color: #dc2626;
    transform: scale(1.05);
}

.btn-remove-background svg {
    width: 16px;
    height: 16px;
}

/* Slider Styles */
.slider-container {
    margin: 0.5rem 0;
}

input[type="range"].slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-gray-100);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

input[type="range"].slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

input[type="range"].slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

input[type="range"].slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

input[type="range"].slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

input[type="range"].slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--bg-gray-100);
    border-radius: 3px;
}

input[type="range"].slider::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--bg-gray-100);
    border-radius: 3px;
}

input[type="range"].slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input[type="range"].slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

input[type="range"].slider:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 640px) {
    .applications-grid {
        grid-template-columns: 1fr;
    }
    
    .site-title {
        font-size: 1.25rem;
    }
    
    .modal-container {
        padding: 1.5rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
}
