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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
}

.navbar-menu {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.navbar-menu a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

.navbar-menu a:hover {
    color: #3498db;
}

.navbar-user {
    color: #ecf0f1;
    font-weight: 500;
}

/* Main content */
main.container {
    min-height: calc(100vh - 200px);
    padding: 2rem 20px;
}

/* Flash messages */
.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border-left: 4px solid;
}

.flash-success {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.flash-error {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.flash-info {
    background-color: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.auth-box h1 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group textarea {
    font-family: monospace;
    resize: vertical;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.875rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: #666;
}

.auth-footer a {
    color: #3498db;
    text-decoration: none;
}

/* Collection */
.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.collection-stats {
    display: flex;
    gap: 2rem;
    color: #666;
}

/* Search */
.search-container {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.search-form input[type="text"] {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.search-help {
    font-size: 0.875rem;
    color: #666;
}

.search-help a {
    color: #3498db;
    text-decoration: none;
}

.controls {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.sort-controls,
.filter-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-controls {
    gap: 0.5rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.card-item {
    background: white;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.card-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
}

.card-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.card-image {
    position: relative;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.trade-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #f39c12;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 5;
}

.card-image a {
    display: block;
}

.card-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.2s;
}

.card-image a:hover img {
    opacity: 0.9;
}

.card-placeholder {
    width: 100%;
    height: 350px;
    background: #ecf0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7f8c8d;
}

.card-details {
    padding: 1rem;
}

.card-details h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 1.1rem;
}

.card-set {
    font-size: 0.875rem;
    color: #7f8c8d;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.card-quantity {
    font-weight: bold;
    color: #3498db;
    margin-bottom: 0.25rem;
}

.card-type,
.card-mana {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.card-price {
    font-size: 0.875rem;
    color: #27ae60;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
}

/* Card Menu */
.card-menu {
    position: relative;
}

.card-menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    color: #666;
    transition: color 0.2s;
}

.card-menu-btn:hover {
    color: #2c3e50;
}

.card-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    bottom: 100%;
    margin-bottom: 0.25rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 220px;
    padding: 0.5rem 0;
}

.card-menu-dropdown.show {
    display: block;
}

.menu-item {
    padding: 0.5rem 1rem;
}

.menu-item form {
    margin: 0;
}

.quantity-form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.quantity-form-inline label {
    margin: 0;
    font-size: 0.875rem;
}

.quantity-form-inline input {
    width: 60px;
}

.card-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

.quantity-form {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.quantity-form input {
    width: 60px;
}

.rarity-common {
    border-left: 4px solid #95a5a6;
}

.rarity-uncommon {
    border-left: 4px solid #95a5a6;
}

.rarity-rare {
    border-left: 4px solid #f39c12;
}

.rarity-mythic {
    border-left: 4px solid #e74c3c;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 8px;
}

.empty-state h2 {
    margin-bottom: 1rem;
    color: #7f8c8d;
}

.empty-state a {
    color: #3498db;
}

/* Import/Export */
.import-export-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.import-section,
.export-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
}

.import-section h2,
.export-section h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.import-help {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
}

.import-help h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.import-help pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
}

/* Selection Toast */
.selection-toast {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: #2c3e50;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.selection-toast.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.toast-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toast-actions {
    display: flex;
    gap: 0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    margin-top: 1rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Footer */
.footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
}

.footer a {
    color: #3498db;
    text-decoration: none;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .container {
        padding: 0 10px;
    }

    main.container {
        padding: 1rem 10px;
    }

    .navbar .container {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
        align-items: stretch;
    }

    .navbar-brand {
        text-align: center;
        width: 100%;
    }

    .navbar-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
        width: 100%;
    }

    .navbar-menu a,
    .navbar-user {
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .collection-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .collection-stats {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .search-container {
        padding: 1rem;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form input[type="text"] {
        width: 100%;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
    }

    .sort-controls,
    .filter-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .sort-controls select,
    .filter-controls select {
        width: 100%;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card-item {
        max-width: 100%;
    }

    .import-export-container {
        grid-template-columns: 1fr;
    }

    .selection-toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        padding: 0.75rem 1rem;
    }

    .toast-content {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .toast-info {
        text-align: center;
    }

    .toast-actions {
        justify-content: stretch;
    }

    .toast-actions button {
        flex: 1;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .card-menu-dropdown {
        right: auto;
        left: 0;
    }

    .auth-box {
        padding: 1.5rem;
    }
}
