/* HabitWins Contracts CSS - Contract-specific styling */

/* Navigation Container */
/* IMPORTANT: This is SINGLE SOURCE OF TRUTH for .contracts-list gap */
.contracts-list {
    display: flex;
    flex-direction: column;
    gap: 12px !important; /* Override dashboard.css - increased from 8px for better spacing */
    max-height: 230px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Desktop: List height matches map section with scroll for extra contracts */
@media (min-width: 869px) {
    .contracts-list {
        max-height: 580px; /* Match map section height, scroll if more contracts */
    }

    .contract-card {
        min-height: 70px !important; /* Same as mobile for consistency */
        height: 70px !important; /* Enforce consistent height */
        padding: 6px 12px !important; /* Reduced vertical padding for taller buttons */
    }
}

.contract-card {
    background: white;
    border-radius: 8px;
    padding: 4px 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease, background 0.3s ease;
    width: 100%;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
    position: relative; /* Fix timer positioning - timer will be relative to card */
    cursor: pointer; /* Show clickable cursor */
    color: #333; /* Default dark text */
}

/* NEON theme - Dark cards with light text */
[data-theme="neon"] .contract-card {
    background: #1A1A1A !important;
    border: 1px solid rgba(0, 255, 136, 0.2) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    color: #E5E5E5 !important;
}

[data-theme="neon"] .contract-card:hover {
    border-color: rgba(0, 255, 136, 0.4) !important;
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.2) !important;
}

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

/* Theme-Aware Habit Icons */
.theme-habit-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Reward Thumbnail Styles */
.contract-reward-thumbnail {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.contract-reward-thumbnail:hover {
    transform: scale(1.1);
}

.contract-reward-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Button status styles - PENDING (red - not completed today) */
.btn-pending {
    background: white !important; /* White base layer */
    box-shadow: inset 0 0 0 100px rgba(239, 68, 68, 0.25) !important; /* Red overlay */
    color: #DC2626 !important;
    border: 1px solid rgba(239, 68, 68, 0.4) !important;
    font-weight: 600;
    text-align: center !important;
}

.btn-pending:hover {
    box-shadow: inset 0 0 0 100px rgba(239, 68, 68, 0.35) !important; /* Darker red on hover */
    border-color: rgba(239, 68, 68, 0.6) !important;
}

/* Button status styles - COMPLETED (green - goal achieved today) */
.btn-completed {
    background: white !important; /* White base layer */
    box-shadow: inset 0 0 0 100px rgba(16, 185, 129, 0.25) !important; /* Green overlay */
    color: #059669 !important;
    border: 1px solid rgba(16, 185, 129, 0.4) !important;
    font-weight: 600;
    cursor: default !important;
    text-align: center !important;
}

.btn-completed:hover {
    box-shadow: inset 0 0 0 100px rgba(16, 185, 129, 0.25) !important; /* No hover effect when completed */
    border-color: rgba(16, 185, 129, 0.4) !important;
    transform: none !important;
}

/* Button status styles - DISABLED (paused contracts) */
.btn-disabled {
    background: #f8f9fa !important;
    color: #9ca3af !important;
    border: 1px solid #e5e7eb !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

.contract-card.active-timer {
    border: 2px solid #ff4444 !important;
    box-shadow: 0 4px 20px rgba(255, 68, 68, 0.3) !important;
    animation: timerPulse 2s infinite;
}

@keyframes timerPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(255, 68, 68, 0.3);
    }
    50% {
        box-shadow: 0 4px 25px rgba(255, 68, 68, 0.5);
    }
}

/* Map Selected State (Expanded - Progress Map Visible) - Theme-Aware */
.contract-card.map-selected {
    border: 3px solid #FF6B9D !important;
    box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4) !important;
    background: linear-gradient(rgba(255, 107, 157, 0.12), rgba(255, 107, 157, 0.06)), white !important;
}

/* RAINBOW theme - Purple gradient expanded state */
[data-theme="rainbow"] .contract-card.map-selected {
    border: 3px solid #764ba2 !important;
    box-shadow: 0 4px 20px rgba(118, 75, 162, 0.5) !important;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.12) 100%), white !important;
}

/* NEON theme - Neon green glow expanded state */
[data-theme="neon"] .contract-card.map-selected {
    border: 3px solid #00FF88 !important;
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.5), 0 4px 20px rgba(0, 255, 136, 0.3) !important;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.15) 0%, rgba(255, 0, 110, 0.08) 100%), #1A1A1A !important;
}

/* MINIMAL theme - Blue professional expanded state */
[data-theme="minimal"] .contract-card.map-selected {
    border: 2px solid #42a5f5 !important;  /* Blue border - visible on white */
    box-shadow: 0 4px 20px rgba(66, 165, 245, 0.4) !important;
    background: linear-gradient(135deg, rgba(66, 165, 245, 0.15) 0%, rgba(0, 188, 212, 0.12) 100%) !important;  /* Gradient background */
}

/* Info button in selected card - add subtle background for visibility */
.contract-card.map-selected .btn-info {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
}

.contract-card.map-selected .btn-info:hover {
    background: rgba(255, 255, 255, 0.9);
}

.timer-display {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
    z-index: 2;
}

/* Show timer display always when timer is active */
.contract-card.active-timer .timer-display {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    top: -5px !important;
    right: -5px !important;
    z-index: 10 !important;
}

.contract-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.contract-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.contract-icon {
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    color: white;
}

.contract-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
}

/* Contract name text in card - handles long words without spaces */
.contract-name-text {
    font-weight: 600;
    font-size: 13px;
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    line-height: 1.3;
}

.contract-category {
    font-size: 0.75rem;
    color: #666;
}

.contract-status {
    text-align: right;
}

.days-left {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.streak {
    font-size: 0.8rem;
    color: #10B981;
    font-weight: 500;
}

.contract-progress {
    margin-bottom: 12px;
}

.progress-label {
    display: flex;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #666;
}

.progress-bar {
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.contract-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.action-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-track {
    background: #10B981;
    color: white;
}

.btn-track:hover {
    background: #059669;
    transform: translateY(-1px);
}

/* RAINBOW theme - Purple gradient "Wykonaj" button */
[data-theme="rainbow"] .btn-track {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(118, 75, 162, 0.3);
}

[data-theme="rainbow"] .btn-track:hover {
    background: linear-gradient(135deg, #8b5cb3 0%, #7b8ff7 100%);
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.5);
}

/* NEON theme - Neon green "Wykonaj" button */
[data-theme="neon"] .btn-track {
    background: linear-gradient(135deg, #00FF88 0%, #00DD77 100%);
    color: #0A0A0A;
    font-weight: 700;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

[data-theme="neon"] .btn-track:hover {
    background: linear-gradient(135deg, #00FF88 0%, #00FF88 100%);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.7);
}

/* MINIMAL theme - Blue "Wykonaj" button */
[data-theme="minimal"] .btn-track {
    background: linear-gradient(135deg, #42a5f5 0%, #00bcd4 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(66, 165, 245, 0.3);
}

[data-theme="minimal"] .btn-track:hover {
    background: linear-gradient(135deg, #42a5f5 0%, #00bcd4 100%);
    box-shadow: 0 4px 12px rgba(66, 165, 245, 0.5);
    filter: brightness(1.1);
}

/* Contract Card Button Container - Full height buttons */
.contract-card-actions {
    display: flex;
    gap: 8px;
    align-items: stretch;
    align-self: stretch;
}

/* Track button (Wykonaj/Wykonano) - Full height of card */
.btn-track-full-height {
    min-width: 120px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

/* Info button with icon - Fixed small size */
.btn-info {
    background: transparent;
    color: #666;
    border: none;
    width: 38px;
    min-width: 38px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 18px;
    transition: all 0.2s ease;
}

.btn-info:hover {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

/* Menu icon inside info button */
.menu-icon {
    width: 22px;
    height: 22px;
    display: block;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    object-fit: contain;
}

.btn-info:hover .menu-icon {
    opacity: 1;
}

/* Mobile adjustments - Slightly larger buttons */
@media (max-width: 868px) {
    .btn-track-full-height {
        min-width: 125px;
        font-size: 16px;
    }

    .btn-info {
        width: 42px;
        min-width: 42px;
        font-size: 20px;
    }
}

/* Small mobile - Compact buttons */
@media (max-width: 480px) {
    .btn-track-full-height {
        min-width: 110px;
        font-size: 14px;
        padding: 8px 12px;
    }

    .btn-info {
        width: 36px;
        min-width: 36px;
        font-size: 16px;
    }
}

/* Calendar Details Modal - Contract specific */
.habit-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.habit-icon {
    font-size: 1.8rem;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.habit-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 25px;
}

.calendar-day-header {
    text-align: center;
    font-weight: bold;
    padding: 10px 5px;
    background: #667eea;
    color: white;
    border-radius: 5px;
    font-size: 0.85rem;
}

.calendar-day {
    aspect-ratio: 1;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    background: white;
    cursor: pointer;
}

.calendar-day:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.calendar-day.other-month {
    opacity: 0.3;
    cursor: default;
}

.calendar-day.other-month:hover {
    transform: none;
    box-shadow: none;
}

.calendar-day.future {
    background: #f5f5f5;
    cursor: default;
}

.calendar-day.future:hover {
    transform: none;
    box-shadow: none;
}

.calendar-day.has-session {
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
    border-color: #f59e0b;
}

.calendar-day-number {
    font-weight: bold;
    color: #333;
    margin-bottom: 3px;
    font-size: 0.85rem;
}

.calendar-day-stickers {
    display: flex;
    gap: 1px;
    margin-top: 2px;
}

.calendar-sticker {
    font-size: 14px;
}

.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.calendar-stats {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 10px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
}

/* Paused/Inactive Contract Styles */
.contract-card.paused {
    opacity: 0.6;
    background: #f8f9fa !important;
    border: 2px dashed #dee2e6 !important;
}

.contract-card.paused .contract-name {
    color: #6c757d;
}

.contract-card.paused .days-left {
    color: #6c757d;
}

.contract-card.completed {
    background: linear-gradient(rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.1)), white !important;
    border: 2px solid rgba(34, 197, 94, 0.8) !important;
    box-shadow: 0 2px 15px rgba(34, 197, 94, 0.2) !important;
}

/* Mobile responsiveness for contracts */
@media (max-width: 868px) {
    /* ✅ FIXED: Respect dashboard.css gap: 0 setting */
    .contracts-list {
        gap: 0px !important; /* Override desktop gap: 8px for mobile layout */
    }

    /* Mobile contract card sizing - exactly 3 cards fully visible, 4th hidden */
    .contract-card {
        padding: 8px 12px !important; /* Reduced vertical padding for taller buttons */
        min-height: 70px !important; /* Increased height - only 3 cards fit, 4th completely hidden */
        margin-bottom: 4px !important; /* Optimal spacing between cards */
        width: 100% !important; /* Ensure full width on mobile */
        box-sizing: border-box !important; /* Include padding in width calculation */
    }

    .contract-card:last-child {
        margin-bottom: 0 !important; /* Remove margin from last card to eliminate empty space */
    }
}

/* Small mobile (480px) - Smaller cards to fit everything on one screen */
@media (max-width: 480px) {
    .contract-card {
        padding: 6px 10px !important; /* Reduced vertical padding for taller buttons */
        min-height: 58px !important; /* Smaller height to fit dashboard on one screen */
        height: 58px !important; /* Enforce smaller height */
        margin-bottom: 3px !important; /* Tighter spacing */
    }

    .contract-card:last-child {
        margin-bottom: 0 !important; /* Remove margin from last card to eliminate empty space */
    }
}

@media (max-width: 768px) {
    /* Note: .contracts-list sizing is handled by dashboard.css for better mobile layout */

    .contract-name {
        font-size: 0.85rem; /* Slightly larger for better readability */
    }

    .contract-category {
        font-size: 0.75rem;
    }

    .days-left {
        font-size: 0.9rem;
    }

    .streak {
        font-size: 0.8rem;
    }
}

@media (max-width: 600px) {
    .calendar-controls {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        padding: 10px;
    }

    .nav-btn {
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        white-space: nowrap;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .contract-icon {
        width: 24px;
        height: 24px;
        font-size: 1rem;
    }

    .timer-display {
        font-size: 9px;
        padding: 1px 4px;
    }
}