/* Manage Openings - Dashboard Styles */
:root {
    --accent-green: #2ecc71;
    --accent-red: #e74c3c;
    --bg-dark: #0b0f14;
    --card-bg: rgba(30, 41, 59, 0.4);
    --glass-border: rgba(255, 255, 255, 0.05);
    --text-muted: #94a3b8;
}

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: 'Cairo', sans-serif;
}

.manage-container {
    max-width: 1200px;
    margin: 100px auto 50px;
    padding: 0 20px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.stage-filter-bar {
    display: flex;
    gap: 10px;
    margin: 0 0 24px;
    flex-wrap: wrap;
}

.stage-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}

.stage-filter-btn i { font-size: 0.85rem; }

.stage-filter-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.15);
}

.stage-filter-btn.active {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(46, 204, 113, 0.25);
}

.dashboard-header h1 {
    font-weight: 700;
    font-size: 1.8rem;
    color: #fff;
    margin: 0;
}

.search-bar {
    position: relative;
    max-width: 400px;
    width: 100%;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px 12px 45px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: #fff;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.2);
}

.search-bar i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.openings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* Professional Opening Cards */
.opening-card {
    position: relative;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.85), rgba(30, 41, 59, 0.5));
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 22px;
    padding: 24px;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 240px;
    overflow: hidden;
    z-index: 1;
}

.opening-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #00d2ff, #a855f7);
    opacity: 0.6;
    transition: opacity 0.3s, height 0.3s;
    z-index: 2;
}

.opening-card.stage-opening::before { background: linear-gradient(90deg, #3b82f6, #06b6d4); }
.opening-card.stage-middlegame::before { background: linear-gradient(90deg, #8b5cf6, #d946ef); }
.opening-card.stage-endgame::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.opening-card:hover {
    transform: translateY(-8px);
    border-color: rgba(0, 210, 255, 0.2);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45), 0 0 25px rgba(0, 210, 255, 0.08);
}

.opening-card:hover::before {
    opacity: 1;
    height: 5px;
}

/* Background decorative icon */
.opening-bg-icon {
    position: absolute;
    bottom: -18px;
    right: -18px;
    font-size: 6.5rem;
    color: rgba(255, 255, 255, 0.02);
    transform: rotate(-15deg);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 0;
}

[dir="rtl"] .opening-bg-icon {
    right: auto;
    left: -18px;
    transform: rotate(15deg);
}

.opening-card:hover .opening-bg-icon {
    color: rgba(255, 255, 255, 0.045);
    transform: scale(1.15) rotate(-8deg);
}
[dir="rtl"] .opening-card:hover .opening-bg-icon {
    transform: scale(1.15) rotate(8deg);
}

/* Card Header Area */
.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    z-index: 2;
}

.eco-badge {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    background: rgba(46, 204, 113, 0.1);
    color: #2ecc71;
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid rgba(46, 204, 113, 0.2);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.05);
}

.stage-badge {
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    padding: 5px 12px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 6px;
}

.stage-badge i {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* Dynamic icons matching stages */
.stage-opening .eco-badge { color: #38bdf8; background: rgba(56, 189, 248, 0.1); border-color: rgba(56, 189, 248, 0.2); }
.stage-middlegame .eco-badge { color: #c084fc; background: rgba(192, 132, 252, 0.1); border-color: rgba(192, 132, 252, 0.2); }
.stage-endgame .eco-badge { color: #fbbf24; background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.2); }

/* Card Typography */
.opening-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.5;
    margin: 0 0 18px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    z-index: 2;
    transition: color 0.3s;
}

.opening-card:hover .opening-title {
    color: #00d2ff;
}

/* Stats Grid */
.stats-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
    padding-bottom: 20px;
    z-index: 2;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 7px 14px;
    font-size: 0.85rem;
    color: #cbd5e1;
    transition: background 0.3s, border-color 0.3s;
}

.opening-card:hover .stat-pill {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.stat-pill i {
    font-size: 0.85rem;
    color: #38bdf8;
    opacity: 0.9;
}

.stage-middlegame .stat-pill i { color: #c084fc; }
.stage-endgame .stat-pill i { color: #fca5a5; }

/* Action Buttons */
.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-top: 20px;
    margin-top: 0;
    z-index: 2;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.btn-edit-new {
    background: rgba(0, 210, 255, 0.06);
    color: #00d2ff;
    border: 1px solid rgba(0, 210, 255, 0.2);
}

.btn-edit-new:hover {
    background: #00d2ff;
    color: #060a0f;
    border-color: #00d2ff;
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.35);
    transform: translateY(-2px);
}

.btn-delete-new {
    background: rgba(239, 68, 68, 0.06);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-delete-new:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.35);
    transform: translateY(-2px);
}

/* Spinner */
.loading-wrapper {
    display: none;
    justify-content: center;
    padding: 50px;
}

.loading-wrapper.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--glass-border);
    border-top: 4px solid var(--accent-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* RTL Adjustments */
[dir="rtl"] .search-bar i {
    left: auto;
    right: 15px;
}
[dir="rtl"] .search-bar input {
    padding: 12px 45px 12px 20px;
}
[dir="rtl"] .opening-stats span i {
    margin-right: 0;
    margin-left: 5px;
}
