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

:root {
    --card-padding: 26px;
    --icon-size: 42px;
    --icon-size-small: 26px;
    --icon-size-large: 62px;
    --title-size: 16px;
    --desc-size: 10px;
    --status-padding: 3px;
    --grid-min-width: 180px;
    --grid-gap: 20px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

body.modal-open {
    overflow: hidden;
}

.container {
    max-width: 1200px;
    width: 100%;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 50px;
    position: relative;
}

header h1 {
    font-size: 48px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header p {
    font-size: 18px;
    opacity: 0.9;
}

.settings-btn {
    position: absolute;
    top: 0;
    right: 160px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.logout-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--grid-min-width), 1fr));
    gap: var(--grid-gap);
    margin-bottom: 40px;
}

.app-card {
    background: white;
    border-radius: 10px;
    padding: var(--card-padding);
    text-align: center;
    text-decoration: none;
    color: #333;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.app-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.app-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.app-icon {
    font-size: var(--icon-size);
    margin-bottom: 13px;
    transition: all 0.3s ease;
}

.app-icon.icon-size-small {
    font-size: var(--icon-size-small);
}

.app-icon.icon-size-medium {
    font-size: var(--icon-size);
}

.app-icon.icon-size-large {
    font-size: var(--icon-size-large);
}

.app-card h2 {
    font-size: var(--title-size);
    margin-bottom: 6px;
    color: #333;
}

.app-card p {
    font-size: var(--desc-size);
    color: #666;
    margin-bottom: 13px;
    line-height: 1.5;
}

.app-status {
    display: inline-block;
    padding: var(--status-padding) 10px;
    border-radius: 13px;
    font-size: var(--desc-size);
    font-weight: 600;
    text-transform: uppercase;
}

.app-status.online {
    background: #e8f5e9;
    color: #2e7d32;
}

.app-status.offline {
    background: #ffebee;
    color: #c62828;
}

.app-card.placeholder {
    opacity: 0.8;
    cursor: pointer;
    border: 2px dashed #ddd;
    background: rgba(255, 255, 255, 0.5);
}

.app-card.placeholder:hover {
    opacity: 1;
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.app-card.placeholder::before {
    display: none;
}

.app-card > a {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
}

footer {
    text-align: center;
    color: white;
    opacity: 0.8;
    font-size: 14px;
}

/* Blur effect for authenticated state */
.container.blurred {
    filter: blur(10px);
    pointer-events: none;
    user-select: none;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 50px 40px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: slideInLogin 0.4s ease;
}

@keyframes slideInLogin {
    from {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

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

.login-header h1 {
    font-size: 32px;
    margin-bottom: 10px;
    color: #333;
}

.login-header p {
    font-size: 16px;
    color: #666;
}

/* Honeypot field - completely hidden */
#username {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.login-error {
    color: #f44336;
    font-size: 14px;
    margin-top: 10px;
    margin-bottom: 10px;
    text-align: center;
    min-height: 20px;
}

.btn-full {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

/* Edit button for custom apps */
.edit-btn {
    position: absolute;
    top: 10px;
    right: 50px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #2196F3;
    color: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
}

.edit-btn:hover {
    background: #1976D2;
    transform: scale(1.1);
}

/* Delete button for custom apps */
.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f44336;
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    overflow-y: auto;
    padding: 20px 0;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 0;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
    overflow-y: auto;
    margin: auto;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.close {
    font-size: 32px;
    font-weight: 300;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close:hover {
    color: #333;
}

/* Form Styles */
#addAppForm {
    padding: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group select {
    cursor: pointer;
    background-color: white;
}

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

/* Icon Picker */
.icon-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.icon-option {
    font-size: 32px;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.icon-option:hover {
    border-color: #667eea;
    transform: scale(1.1);
}

.icon-option.selected {
    border-color: #667eea;
    background: #f0f0ff;
    transform: scale(1.1);
}

.selected-icon-display {
    font-size: 14px;
    color: #666;
    margin-top: 10px;
}

.selected-icon-display span {
    font-size: 20px;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Drag Handle */
.drag-handle {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    font-size: 18px;
    color: #999;
    cursor: move;
    opacity: 0;
    transition: opacity 0.2s;
    user-select: none;
    z-index: 5;
}

.app-card:hover .drag-handle {
    opacity: 1;
}

/* Drag and Drop States */
.app-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.app-card.drag-over {
    border: 2px dashed #667eea;
    background: #f0f0ff;
}

/* Size Selector */
.size-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.size-option {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.size-option:hover {
    border-color: #667eea;
    background: #f8f8ff;
}

.size-option.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Color Picker */
.color-picker-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.color-picker-container input[type="color"] {
    width: 80px;
    height: 50px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    padding: 5px;
}

.color-picker-container input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-container input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.btn-reset-color {
    padding: 10px 16px;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
}

.btn-reset-color:hover {
    background: #e0e0e0;
    border-color: #ccc;
}

.color-preview-text {
    font-size: 12px;
    color: #999;
    margin: 5px 0 0 0;
    font-style: italic;
}

/* Settings Content */
.settings-content {
    padding: 30px;
}

.settings-content select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-content select:focus {
    outline: none;
    border-color: #667eea;
}

.font-size-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.font-size-controls button {
    width: 40px;
    height: 40px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.font-size-controls button:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

.font-size-controls span {
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    font-size: 18px;
    color: #333;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
}

/* Checkbox Label Styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

.checkbox-label span {
    font-size: 14px;
    color: #333;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 36px;
    }

    .settings-btn {
        right: auto;
        left: 0;
        top: 60px;
    }

    .logout-btn {
        right: 0;
        top: 60px;
    }

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

    .icon-picker {
        grid-template-columns: repeat(4, 1fr);
    }

    .modal-content {
        width: 95%;
    }
}
