/* Mobile-First Modern Design */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1f2937;
    --light: #f9fafb;
    --gray: #6b7280;
    --gray-light: #e5e7eb;
    --white: #ffffff;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 0.5rem;
    --radius-sm: 0.375rem;
    --radius-lg: 0.75rem;
}

* {
    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: var(--dark);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
    padding: 1.5rem;
    text-align: center;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

header p {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Navigation */
.top-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.top-nav a,
.top-nav button {
    padding: 0.5rem 1rem;
    color: var(--white);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.top-nav a:hover,
.top-nav button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.top-nav a.active {
    background: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

.top-nav form {
    display: inline;
}

/* Main Content */
main {
    flex: 1;
    padding: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--primary);
    color: var(--white);
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray);
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

/* Auth Form */
.auth-form {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--dark);
    font-size: 1.5rem;
}

/* Messages */
.error-message,
.success-message,
.info-message {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.success-message {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.info-message {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.card-item {
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    position: relative;
    min-height: 200px;
    perspective: 1000px;
    width: 100%;

    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Disable text selection/callout on cards */
.card-item,
.card-item * {
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
}

.card-item:hover:not(.flipped) {
    transform: translateY(-4px);
}

.card-flip-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 200px;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.card-item.flipped .card-flip-container {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: var(--white);
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow);
    text-align: center;
    font-size: 1.125rem;
    color: var(--dark);
    word-wrap: break-word;
}

.card-back {
    transform: rotateY(180deg);
}

.card-item:hover:not(.show-actions) .card-front,
.card-item:hover:not(.show-actions) .card-back {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.card-actions {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 0.5rem;
    justify-content: center;
    width: calc(100% - 3rem);
    z-index: 10;
    background: rgba(255, 255, 255, 0.98);
    padding: 0.75rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--primary);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.card-item.show-actions .card-actions {
    display: flex;
}

.card-actions button,
.card-actions a {
    flex: 1;
    max-width: 120px;
}

/* Collections Grid */
.collections-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.collection-item {
    background: var(--white);
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.collection-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.collection-item h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.collection-item p {
    font-size: 0.875rem;
    color: var(--gray);
    margin-bottom: 1rem;
}

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

/* Actions Bar */
.actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.empty-state p {
    font-size: 0.875rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--gray);
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

table th,
table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-light);
    font-size: 0.875rem;
}

table th {
    background: var(--light);
    font-weight: 600;
    color: var(--dark);
}

table tr:hover {
    background: var(--light);
}

table tr:last-child td {
    border-bottom: none;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--gray-light);
    overflow-x: auto;
}

.tab {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray);
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--gray-light);
    color: var(--dark);
}

/* Welcome Page */
.welcome {
    text-align: center;
    padding: 3rem 1rem;
}

.welcome h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--dark);
}

.welcome p {
    font-size: 1.125rem;
    color: var(--gray);
    margin-bottom: 2rem;
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 3rem 1rem;
}

.error-page h1 {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.error-page h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--dark);
}

.error-page p {
    color: var(--gray);
    margin-bottom: 2rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    background: var(--gray-light);
    color: var(--dark);
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Responsive Design */
@media (min-width: 640px) {
    body {
        padding: 1.5rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .collections-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .top-nav {
        justify-content: flex-start;
    }
}

@media (min-width: 768px) {
    main {
        padding: 2rem;
    }

    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .collections-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .auth-form {
        padding: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }

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

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

