/* Liverpool Rummy Bot Styles */

/* Main container layout */
.game-container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    max-width: 1800px;
    margin: 0 auto;
    min-height: 80vh;
}

/* Controls Panel (Left) */
.controls-panel {
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 3px 10px var(--shadow-color);
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.control-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.setup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.setup-row label {
    font-weight: bold;
    color: var(--text-color);
}

/* Score table styles */
.score-table {
    width: 100%;
    overflow: hidden;
}

#scoreTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

#scoreTable th,
#scoreTable td {
    padding: 2px 4px;
    text-align: center;
    border: 1px solid #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#scoreTable th {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

#scoreTable th:first-child {
    width: 15%;
}

#scoreTable th:not(:first-child) {
    width: 21.25%;
}

.score-input {
    width: 100%;
    padding: 1px 2px;
    border: 1px solid #ccc;
    border-radius: 2px;
    text-align: center;
    font-size: 11px;
    box-sizing: border-box;
}

.editable-player-name {
    background: transparent;
    border: 1px solid transparent;
    color: white;
    font: inherit;
    text-align: center;
    width: 100%;
    cursor: text;
    padding: 1px 2px;
    border-radius: 2px;
    box-sizing: border-box;
    font-size: 11px;
}

.editable-player-name:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.editable-player-name:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.2);
}

.total-row {
    background-color: #f5f5f5;
    font-weight: bold;
}

/* Game info */
.game-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Bot recommendation panel */
.bot-output {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    min-height: 100px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    white-space: pre-wrap;
}

.bot-button {
    background-color: var(--accent-color);
    color: var(--dark-color);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    transition: background-color 0.3s;
}

.bot-button:hover {
    background-color: #ffb300;
}

/* Game Table (Center) */
.game-table {
    background-color: #2e7d4f;
    border-radius: 20px;
    padding: 20px;
    position: relative;
    display: grid;
    grid-template-areas: 
        ".     north  ."
        "west  center east"
        ".     south  .";
    grid-template-rows: 1fr auto 1fr;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    min-height: 600px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Player areas */
.player-area {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.north-player {
    grid-area: north;
    justify-self: center;
}

.west-player {
    grid-area: west;
    align-self: center;
}

.east-player {
    grid-area: east;
    align-self: center;
}

.your-hand {
    grid-area: south;
    justify-self: center;
    background-color: rgba(255, 255, 255, 0.95);
}

.center-area {
    grid-area: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 20px;
}

/* Player info */
.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

.player-info h4 {
    margin: 0;
    color: var(--primary-color);
}

.card-count {
    font-size: 12px;
    color: var(--muted-text);
    font-weight: bold;
}

/* Player cards areas */
.player-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
    min-height: 60px;
    background-color: #f8f8f8;
    border-radius: 6px;
    padding: 8px;
    border: 2px dashed #ccc;
}

.hand-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    min-height: 80px;
    background-color: #f0f8ff;
    border-radius: 6px;
    padding: 10px;
    border: 2px dashed #4a90e2;
}

.laid-down-area {
    min-height: 50px;
    background-color: #e8f5e8;
    border-radius: 6px;
    padding: 8px;
    border: 1px solid #90ee90;
    margin-bottom: 10px;
}

/* Deck and discard pile */
.deck-area {
    display: flex;
    gap: 20px;
    align-items: center;
}

.deck,
.discard-pile {
    text-align: center;
}

.deck .card-img,
.discard-pile .card-img {
    width: 60px;
    height: 84px;
    cursor: pointer;
    transition: transform 0.2s;
}

.deck .card-img:hover,
.discard-pile .card-img:hover {
    transform: scale(1.05);
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hand-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.action-btn:hover {
    background-color: #1976d2;
}

.action-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Card Library (Right) */
.card-library {
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 3px 10px var(--shadow-color);
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
    max-height: 90vh;
    overflow-y: auto;
}


.card-search {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-search input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    margin-bottom: 15px;
}

.add-to-hand-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
    width: 100%;
}

.add-to-hand-btn:hover {
    background-color: #1976d2;
}

.add-to-hand-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}
.suit-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.suit-section:last-child {
    border-bottom: none;
}

.suit-section h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

/* Override color for black suits */
.suit-section[data-suit="clubs"] h4,
.suit-section[data-suit="spades"] h4 {
    color: #333;
}

/* Keep red for red suits */
.suit-section[data-suit="hearts"] h4,
.suit-section[data-suit="diamonds"] h4 {
    color: #d32f2f;
}

.suit-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
    gap: 5px;
}

.suit-cards .card-img {
    width: 35px;
    height: 49px;
    cursor: grab;
    transition: transform 0.2s;
    border-radius: 4px;
}

.suit-cards .card-img:hover {
    transform: scale(1.1);
    z-index: 10;
    position: relative;
}

.suit-cards .card-img:active {
    cursor: grabbing;
}

/* Card styling for game areas */
.player-cards .card-img,
.hand-area .card-img,
.laid-down-area .card-img {
    width: 45px;
    height: 63px;
    cursor: pointer;
    transition: transform 0.2s;
    border-radius: 4px;
}

.hand-area .card-img:hover {
    transform: translateY(-10px);
}

/* Drag and drop states */
.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.drop-zone {
    background-color: #e3f2fd !important;
    border: 2px dashed #2196f3 !important;
}

.drop-zone-valid {
    background-color: #e8f5e8 !important;
    border: 2px dashed #4caf50 !important;
}

.drop-zone-invalid {
    background-color: #ffebee !important;
    border: 2px dashed #f44336 !important;
}

.drop-zone-invalid::after {
    content: "Cannot drop face-down cards here";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #f44336;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.close-modal:hover {
    color: #333;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

/* Responsive design */
@media (max-width: 1400px) {
    .game-container {
        grid-template-columns: 250px 1fr 250px;
    }
}

@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 15px;
    }
    
    .controls-panel,
    .card-library {
        position: static;
        max-height: none;
    }
    
    .game-table {
        order: 2;
        min-height: 500px;
    }
    
    .controls-panel {
        order: 1;
    }
    
    .card-library {
        order: 3;
    }
}

@media (max-width: 768px) {
    .game-table {
        padding: 10px;
        gap: 10px;
        min-height: 400px;
        grid-template-areas: 
            "north"
            "center" 
            "west"
            "east"
            "south";
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto;
    }
    
    .center-area {
        order: 2;
    }
    
    .player-area {
        padding: 10px;
    }
    
    .suit-cards {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Animations */
@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

.card-flip {
    animation: cardFlip 0.5s ease-in-out;
}

@keyframes cardDeal {
    from {
        transform: translate(-100px, -100px) rotate(180deg);
        opacity: 0;
    }
    to {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
}

.card-deal {
    animation: cardDeal 0.3s ease-out;
}

/* Highlight effects */
.card-selected {
    box-shadow: 0 0 0 2px #ffc107;
    transform: scale(1.05);
}

.set-highlight {
    background-color: rgba(76, 175, 80, 0.2);
    border: 2px solid #4caf50;
}

.run-highlight {
    background-color: rgba(33, 150, 243, 0.2);
    border: 2px solid #2196f3;
}

/* Bot recommendation styles */
.bot-output .recommendation {
    background-color: #e8f5e8;
    border-left: 4px solid #4caf50;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}

.bot-output .reasoning {
    color: #666;
    font-style: italic;
    margin-top: 8px;
}

.bot-output .probability {
    font-weight: bold;
    color: #2196f3;
}

/* Card back styling for face-down cards */
.card-img[data-card-id="back"] {
    background: linear-gradient(45deg, #1a1a2e, #16213e);
    border: 1px solid #333;
}

/* Special card indicators */
.wildcard-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: #ffc107;
    color: #333;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Unavailable cards (grayed out) */
.card-img.unavailable {
    opacity: 0.3 !important;
    filter: grayscale(100%) !important;
    cursor: not-allowed !important;
}

.card-img.unavailable:hover {
    transform: none !important;
}

/* Face-down cards */
.face-down-card {
    border: 2px solid #333;
    border-radius: 6px;
}

/* Placeholder cards for other players */
.placeholder-card {
    width: 45px;
    height: 63px;
    cursor: grab;
    transition: transform 0.2s;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.placeholder-card:hover {
    transform: scale(1.05);
}

.placeholder-card:active {
    cursor: grabbing;
}

/* Discard selection modal */
.discard-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 10px;
}

/* Empty discard pile styling */
#discardPile:empty {
    min-width: 60px;
    min-height: 84px;
    border: 2px dashed #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    text-align: center;
}

#discardPile:empty::after {
    content: "Face Up";
    white-space: pre;
}

/* Unavailable cards display */
#unavailableCardsArea .card-img {
    width: 35px; /* Match library size */
    height: 49px; /* Match library size */
    opacity: 0.4;
    border-radius: 2px;
}

/* Red suits keep color, black suits get greyscale */
#unavailableCardsArea .card-img[data-card-id*="h"],
#unavailableCardsArea .card-img[data-card-id*="d"] {
    filter: brightness(0.6) saturate(0.8); /* Darken but keep red */
}

#unavailableCardsArea .card-img[data-card-id*="c"],
#unavailableCardsArea .card-img[data-card-id*="s"] {
    filter: grayscale(100%) brightness(0.6); /* Greyscale for black suits */
}