/* Stiva Deck Builder - Frontend Styles */
:root {
    --stiva-primary: #c1121f;
    --stiva-primary-dark: #8f0d17;
    --stiva-secondary: #f0eadc;
    --stiva-success: #10b981;
    --stiva-warning: #f59e0b;
    --stiva-danger: #ef4444;
    --stiva-gray-50: #f9fafb;
    --stiva-gray-100: #f3f4f6;
    --stiva-gray-200: #e5e7eb;
    --stiva-gray-300: #d1d5db;
    --stiva-gray-400: #9ca3af;
    --stiva-gray-500: #6b7280;
    --stiva-gray-600: #4b5563;
    --stiva-gray-700: #374151;
    --stiva-gray-800: #1f2937;
    --stiva-gray-900: #111827;
}

.stiva-deck-builder,
.stiva-my-decks {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.stiva-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    min-height: 300px;
}

.stiva-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--stiva-gray-200);
    border-top-color: var(--stiva-primary);
    border-radius: 50%;
    animation: stiva-spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes stiva-spin {
    to {
        transform: rotate(360deg);
    }
}

.stiva-login-prompt {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 2rem;
}

.stiva-login-card {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.stiva-login-card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--stiva-gray-800);
}

.stiva-login-card p {
    color: var(--stiva-gray-600);
    margin-bottom: 1.5rem;
}

.stiva-login-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.stiva-login-actions .button {
    padding: 0.5rem 1.5rem;
    text-decoration: none;
}

/* Deck Builder Layout */
.stiva-builder-visual {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    background: #f6f0ed;
    padding: 1rem;
    width: 100%;
}

@media (max-width: 1024px) {
    .stiva-builder-visual {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stiva-builder-visual {
        grid-template-columns: 1fr;
    }
    .stiva-visual-left,
    .stiva-visual-right {
        display: none;
    }
    .stiva-builder-visual[data-mobile-tab="deck"] .stiva-visual-left {
        display: block;
    }
    .stiva-builder-visual[data-mobile-tab="search"] .stiva-visual-right {
        display: flex;
    }
}

.stiva-visual-left {
    background: #ffffff;
    border-radius: 12px;
    padding: 1rem;
    color: #1f2937;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    min-width: 0;
}

.stiva-visual-right {
    background: #ffffff;
    border-radius: 12px;
    padding: 1rem;
    color: #1f2937;
    max-height: calc(100vh - 140px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    min-width: 320px;
}

.stiva-mobile-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
}

.stiva-mobile-nav {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}

.stiva-mobile-tab {
    padding: 0.75rem;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.stiva-mobile-tab.active {
    background: #1d4ed8;
}

@media (max-width: 768px) {
    .stiva-mobile-nav {
        display: grid;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: env(safe-area-inset-bottom, 0) 0 8px;
        background: #0b1220;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 9999;
        grid-template-columns: repeat(3, 1fr);
    }

    .stiva-mobile-tab {
        border-radius: 0;
        border: 0;
        margin: 0;
    }
}

/* Search Panel */
.stiva-mode-toggle,
.stiva-import-toggle {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stiva-mode-btn,
.stiva-mode-subbtn {
    padding: 0.65rem 0.85rem;
    border: 1px solid #1195ad;
    background: #c1121f;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: #fff;
    transition: all 0.2s;
}

.stiva-mode-btn.active,
.stiva-mode-subbtn.active {
    background: #8f0d17;
    border-color: #8f0d17;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.stiva-search-panel {
    background: #faf6f2;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.stiva-search-input-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.stiva-search-input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    border: 1px solid #d7c7b4;
    border-radius: 4px;
    font-size: 0.95rem;
    background: #fff;
    color: #1f2937;
}

.stiva-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--stiva-gray-400);
}

.stiva-search-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stiva-filter-select {
    flex: 1;
    min-width: 150px;
    padding: 0.5rem;
    border: 1px solid var(--stiva-gray-300);
    border-radius: 4px;
    background: white;
}

/* Search Results */
.stiva-search-results {
    background: #1f262e;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 300px;
}

.stiva-results-header {
    padding: 0.75rem 1rem;
    background: #c1121f;
    color: #fff;
    font-weight: 700;
}

.stiva-results-list {
    overflow-y: auto;
    overflow-x: hidden;
}

.stiva-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #2f3945;
    color: #f5f7fb;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}

.stiva-result-item:hover {
    background-color: #27303b;
}

.stiva-result-image {
    width: 50px;
    height: 70px;
    border-radius: 4px;
    object-fit: cover;
    background: #0f172a;
}

.stiva-result-info {
    flex: 1;
    min-width: 0;
}

.stiva-result-name {
    font-weight: 700;
    color: #f5f7fb;
}

.stiva-result-type {
    font-size: 0.85rem;
    color: #cbd5e1;
}

.stiva-result-card {
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
}

.stiva-result-thumb {
    width: 50px;
    flex-shrink: 0;
}

.stiva-result-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    margin-left: auto;
}

.stiva-quantity-display {
    min-width: 36px;
    padding: 0.4rem 0.55rem;
    text-align: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-weight: 700;
}

.stiva-quantity-btn {
    min-width: 34px;
    height: 34px;
    border-radius: 6px;
}

/* Import Panel */
.stiva-import-panel {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stiva-import-body {
    margin-top: 1rem;
    display: grid;
    gap: 0.75rem;
}

.stiva-import-label {
    font-weight: 600;
    color: var(--stiva-gray-700);
}

.stiva-import-textarea {
    width: 100%;
    min-height: 180px;
    border: 1px solid var(--stiva-gray-300);
    border-radius: 6px;
    padding: 0.75rem;
    font-family: monospace;
    resize: vertical;
}

.stiva-import-file {
    border: 1px solid var(--stiva-gray-300);
    border-radius: 6px;
    padding: 0.65rem;
}

.stiva-import-hint {
    font-size: 0.875rem;
    color: var(--stiva-gray-600);
    margin: 0;
}

/* Deck Panel */
.stiva-deck-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.stiva-header-left {
    flex: 1;
}

.stiva-deck-name-input {
    display: none;
}

.stiva-deck-name-display {
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #3a4552;
    background: #151b23;
    color: #f5f7fb;
    font-weight: 700;
    word-break: break-all;
}

.stiva-header-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.stiva-cost-pill,
.stiva-total-pill {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    background: #0c7184;
    color: #fff;
    font-weight: 700;
}

.stiva-total-pill.met {
    background: #198754;
}

.stiva-total-pill.not-met {
    background: #dc3545;
}

.stiva-deck-sections {
    display: grid;
    gap: 0.75rem;
}

.stiva-deck-section {
    border-radius: 6px;
    padding: 0.75rem;
    color: #fff;
}

.stiva-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #f5f7fb;
    margin-bottom: 0.5rem;
}

.stiva-section-title {
    font-weight: 700;
}

.stiva-section-count {
    font-size: 0.875rem;
}

.stiva-deck-items {
    min-height: 120px;
    background: rgba(0,0,0,0.02);
    border-radius: 0;
    padding: 0;
    display: grid;
    gap: 0;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
}

@media (min-width: 1100px) {
    .stiva-deck-items {
        grid-template-columns: repeat(10, minmax(70px, 1fr));
    }
}

.stiva-deck-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: #fff;
    cursor: grab;
}

.stiva-deck-slot.empty {
    justify-content: center;
    font-size: 0.9rem;
    color: #cbd5e1;
    cursor: default;
}

.stiva-deck-slot-image {
    width: 100%;
    max-width: 90px;
    height: auto;
    aspect-ratio: 59 / 86;
    object-fit: cover;
    border-radius: 0;
    background: #0f172a;
}

.stiva-db-builder-page .entry-title,
.stiva-db-builder-page .page-title {
    display: none;
}

.stiva-deck-slot-info {
    width: 100%;
    text-align: center;
}

.stiva-qty-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: #c1121f;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.stiva-app-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.stiva-app-modal-content {
    background: #1c2430;
    color: #f5f7fb;
    padding: 1.5rem;
    border-radius: 10px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

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

.stiva-deck-slot-name {
    font-weight: 700;
}

.stiva-deck-slot-qty {
    font-size: 0.9rem;
    color: #cbd5e1;
}

.stiva-deck-slot-controls {
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 0.35rem;
    align-items: center;
}

.stiva-quantity-btn {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255,255,255,0.6);
    background: transparent;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.stiva-quantity-input {
    width: 60px;
    padding: 0.25rem 0.35rem;
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.stiva-deck-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.stiva-btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
}

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

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

.stiva-btn-secondary {
    background: var(--stiva-gray-100);
    color: var(--stiva-gray-700);
}

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

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

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

.stiva-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* My Decks */
.stiva-my-decks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stiva-my-decks-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    font-size: 0.9rem;
    color: #94a3b8;
}

.stiva-my-decks-summary span {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
}

.stiva-my-decks-toolbar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
}

.stiva-my-decks-search {
    flex: 1;
    min-width: 220px;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #0b1220;
    color: #fff;
    font-size: 0.95rem;
}

.stiva-my-decks-search::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.stiva-my-decks-sort {
    width: 180px;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #0b1220;
    color: #fff;
}

.stiva-my-decks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.stiva-deck-card {
    background: #0b1220;
    border-radius: 18px;
    overflow: hidden;
    color: #fff;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stiva-deck-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
}

.stiva-deck-cover {
    height: 150px;
    position: relative;
    background: linear-gradient(180deg, rgba(245, 245, 245, 0.1), rgba(12, 17, 33, 0.8));
}

.stiva-deck-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.stiva-deck-cover-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b, #111827);
}

.stiva-deck-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.stiva-deck-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.stiva-deck-title {
    margin: 0;
    font-size: 1.25rem;
}

.stiva-deck-card-id {
    font-size: 0.75rem;
    color: #94a3b8;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.stiva-deck-card-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stiva-deck-card-meta {
    font-size: 0.85rem;
    color: #cbd5f5;
}

.stiva-deck-card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

@media (min-width: 640px) {
    .stiva-deck-card-actions {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.stiva-deck-card-actions .stiva-btn {
    font-size: 0.8rem;
    padding: 0.65rem 0.75rem;
}

.stiva-empty-state-premium {
    background: linear-gradient(135deg, #111827, #1f2937);
    border-radius: 18px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
    color: #f8fafc;
}

.stiva-empty-state-content {
    max-width: 420px;
    margin: 0 auto;
}

.stiva-empty-state-label {
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.stiva-empty-state-premium h3 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stiva-empty-state-premium p {
    color: #cbd5f5;
    margin-bottom: 1.25rem;
}

.stiva-empty-search {
    border-radius: 16px;
    padding: 2.5rem 1.5rem;
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    color: #e2e8f0;
}

/* Toast Notifications */
.stiva-toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
}

.stiva-toast {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    min-width: 300px;
    animation: stiva-slide-in 0.3s ease-out;
}

@keyframes stiva-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.stiva-toast-icon {
    margin-right: 0.75rem;
    font-size: 1.25rem;
}

.stiva-toast-success .stiva-toast-icon {
    color: var(--stiva-success);
}

.stiva-toast-error .stiva-toast-icon {
    color: var(--stiva-danger);
}

.stiva-toast-content {
    flex: 1;
}

.stiva-toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stiva-toast-message {
    font-size: 0.875rem;
    color: var(--stiva-gray-600);
}

/* Modal */
.stiva-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.stiva-modal.active {
    display: flex;
}

.stiva-export-modal {
    background: rgba(2, 6, 23, 0.8);
}

.stiva-modal-content {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.stiva-modal-header {
    margin-bottom: 1.5rem;
}

.stiva-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--stiva-gray-800);
    margin: 0;
}

.stiva-modal-body {
    margin-bottom: 1.5rem;
}

.stiva-modal-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--stiva-gray-300);
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.stiva-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.stiva-export-modal .stiva-modal-content {
    max-width: 520px;
    width: min(90vw, 520px);
    background: #020617;
    color: #fff;
    border-radius: 20px;
    padding: 2rem 2.25rem;
    box-shadow: 0 30px 60px rgba(2, 6, 23, 0.5);
}

.stiva-export-meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.stiva-export-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
}

.stiva-export-subtitle {
    color: #94a3b8;
    font-size: 0.95rem;
}

.stiva-export-deck-id,
.stiva-export-share {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    padding: 0.65rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    color: #e2e8f0;
}

.stiva-export-share span {
    font-size: 0.8rem;
    word-break: break-all;
    flex: 1;
}

.stiva-export-copy {
    border: none;
    background: #2563eb;
    border-radius: 8px;
    padding: 0.35rem 0.6rem;
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.stiva-export-copy:hover {
    background: #1d4ed8;
}

.stiva-export-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.stiva-export-action-grid .stiva-btn {
    width: 100%;
    font-size: 0.85rem;
    padding: 0.75rem;
}

/* Legal Text */
.stiva-legal-text {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--stiva-gray-200);
    font-size: 0.75rem;
    color: var(--stiva-gray-500);
    text-align: center;
}

/* Skeleton Loading */
.stiva-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: stiva-skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes stiva-skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.stiva-skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.stiva-skeleton-text:last-child {
    margin-bottom: 0;
}

.stiva-skeleton-img {
    width: 40px;
    height: 40px;
    border-radius: 4px;
}
