:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --danger-color: #ef4444;
    --border-color: #334155;
    --input-bg: #0f172a;

    --font-family: 'Outfit', sans-serif;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 600px;
    /* Mobile-first constraint for desktop view */
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

/* Header */
.app-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: none;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.25rem;
}

.icon-btn:hover {
    color: var(--text-primary);
}

/* Server List */
.server-list {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 100px;
    /* Space for footer */
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Server Card */
.server-card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.1s;
    cursor: grab;
    /* Make entire card draggable */
}

.server-card:active {
    cursor: grabbing;
}

.server-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--bg-color);
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    /* Disable iOS context menu */
}

.sortable-chosen {
    background-color: var(--card-bg);
    transform: scale(1.02);
    box-shadow: 0 8px 16px -4px rgb(0 0 0 / 0.2);
    z-index: 10;
}

.sortable-drag {
    cursor: grabbing;
    opacity: 1;
}

.server-info {
    flex: 1;
    min-width: 0;
    /* Truncate text fix */
}

.server-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.server-price {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.server-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.quantity-input {
    width: 80px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    text-align: right;
    font-size: 1rem;
}

.subtotal {
    font-weight: 600;
    color: var(--accent-color);
    font-size: 0.9rem;
}

.edit-trigger {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: underline;
    cursor: pointer;
    margin-top: 0.25rem;
}

/* Footer */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
}

.total-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-label {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.total-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* Bottom sheet on mobile */
    z-index: 100;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 600px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 1.5rem;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}

.image-upload-container {
    width: 100px;
    height: 100px;
    background-color: var(--input-bg);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

.image-upload-container:hover {
    border-color: var(--accent-color);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
}

#image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.hidden {
    display: none !important;
}

/* Mobile adjustments */
@media (min-width: 600px) {
    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius);
        margin: 1rem;
    }
}