/* ===================================
   MAIN LAYOUT - DARK CLAY THEME
   Updated to use clay theme variables
   =================================== */

* {
  -webkit-user-drag: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-drag: none;
  user-select: none;
  box-sizing: border-box; /* Ensures padding and border are included in element's total width and height */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--clay-darkest); /* Use darkest clay for body background */
    color: var(--clay-text-primary);      /* Use primary text color */
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

main#content-wrapper {
    margin-left: 80px; /* Adjust if side-menu width changes */
    min-height: 100vh;
    background-color: var(--clay-darkest); /* Match body background */
    visibility: hidden; /* Start hidden, revealed by JS */
}

#main-view-column {
    padding: 1.5rem;
    min-height: calc(100vh - 0px); /* Fill viewport height */
    background-color: var(--clay-darkest); /* Match body background */
    box-sizing: border-box;
    max-width: 1400px; /* Optional: Constrain max width */
    margin: 0 auto; /* Center the content column */
}

/* ===================================
   LOADING SCREEN
   Using clay theme variables
   =================================== */

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-dark); /* Use dark gradient */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Ensure it's on top */
    color: var(--clay-text-primary);
}

#loading-screen .loader {
    border: 4px solid var(--clay-dark);       /* Use clay dark for track */
    border-top: 4px solid var(--clay-secondary); /* Use secondary accent for spinner */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px var(--clay-glow); /* Add subtle glow */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-screen p {
    margin-top: 1.5rem;
    font-size: 1rem; /* Slightly smaller text */
    font-weight: 500;
    color: var(--clay-text-secondary); /* Use secondary text color */
    letter-spacing: 0.025em;
}

/* ===================================
   NOTIFICATION SYSTEM
   Using clay theme variables
   =================================== */

#notification-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999; /* Below loading, above modals */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none; /* Allow clicks through container */
}

.notification-popup {
    background: var(--gradient-surface);    /* Use surface gradient */
    color: var(--clay-text-primary);       /* Primary text color */
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;                /* Consistent rounding */
    box-shadow: 0 8px 24px var(--clay-shadow-heavy), 0 0 0 1px var(--clay-border); /* Shadow and border */
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 320px;
    max-width: calc(100vw - 2rem);        /* Ensure it fits on small screens */
    pointer-events: auto;                 /* Allow interaction with notifications */
    border-left: 4px solid var(--clay-secondary); /* Default accent border */
    backdrop-filter: blur(8px);           /* Subtle blur effect */
}

/* Notification Type Styles */
.notification-popup.success {
    background: linear-gradient(135deg, rgba(109, 140, 95, 0.1) 0%, var(--clay-dark) 100%);
    border-left-color: var(--clay-success);
    box-shadow:
        0 8px 24px var(--clay-shadow-heavy),
        0 0 15px rgba(109, 140, 95, 0.2), /* Subtle color glow */
        0 0 0 1px var(--clay-success);
}

.notification-popup.error {
    background: linear-gradient(135deg, rgba(157, 95, 79, 0.1) 0%, var(--clay-dark) 100%);
    border-left-color: var(--clay-error);
    box-shadow:
        0 8px 24px var(--clay-shadow-heavy),
        0 0 15px rgba(157, 95, 79, 0.2), /* Subtle color glow */
        0 0 0 1px var(--clay-error);
}

.notification-popup.warning { /* Added Warning style */
    background: linear-gradient(135deg, rgba(168, 133, 84, 0.1) 0%, var(--clay-dark) 100%);
    border-left-color: var(--clay-warning);
    box-shadow:
        0 8px 24px var(--clay-shadow-heavy),
        0 0 15px rgba(168, 133, 84, 0.2), /* Subtle color glow */
        0 0 0 1px var(--clay-warning);
}

.notification-popup.special {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.15) 0%, var(--clay-dark) 100%); /* Adjusted special color */
    border-left-color: var(--clay-info);
    box-shadow:
        0 8px 24px var(--clay-shadow-heavy),
        0 0 20px rgba(33, 150, 243, 0.3), /* Adjusted special glow */
        0 0 0 1px var(--clay-info);
}
.notification-popup.special .notification-message { /* Ensure message contrast */
    color: var(--clay-text-secondary);
}

.notification-title {
    font-weight: 600; /* Slightly less bold */
    font-size: 0.9375rem; /* Adjusted size */
    margin-bottom: 0.375rem;
    color: inherit; /* Inherit color from parent */
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.notification-message {
    font-size: 0.875rem;
    color: var(--clay-text-secondary); /* Adjusted color */
    line-height: 1.5;
}

/* Notification Animations */
@keyframes slideIn {
    from { transform: translateX(110%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification-popup.fade-out {
    animation: slideOut 0.4s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(110%); opacity: 0; }
}

/* ===================================
   MODAL SYSTEM
   Using clay theme variables
   =================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--clay-overlay); /* Use overlay color */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Above notifications */
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--gradient-dark); /* Dark gradient background */
    padding: 2rem;
    border-radius: 1rem;              /* Larger rounding for modals */
    box-shadow: 0 20px 50px var(--clay-shadow-heavy), 0 0 0 1px var(--clay-border-light); /* Heavy shadow and border */
    max-width: 90%;
    max-height: 90vh;                 /* Limit height */
    overflow-y: auto;                 /* Allow scrolling if content overflows */
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--clay-text-primary);  /* Ensure text color is set */
}

@keyframes modalSlideIn {
    from { transform: scale(0.95) translateY(15px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    color: var(--clay-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal p {
    margin-bottom: 1.5rem;
    color: var(--clay-text-secondary); /* Secondary text color */
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    justify-content: space-between; /* Space out buttons */
    margin-top: 1.5rem;
    gap: 1rem;
}

.modal-buttons button {
    flex-grow: 1; /* Make buttons share space */
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--clay-border); /* Use border variable */
    cursor: pointer;
    font-weight: 600; /* Bolder button text */
    font-size: 0.9375rem;
    text-align: center;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    /* Specific styles are now in clay-theme.css */
}

/* ===================================
   CONFIRMATION MODAL
   =================================== */

#confirmation-modal-overlay {
    z-index: 2001; /* Above other modals if needed */
}

#confirmation-modal-overlay .modal {
    max-width: 400px; /* Constrain width */
}

#confirmation-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--clay-text-primary);
    margin-bottom: 0.75rem;
}

#confirmation-message {
    font-size: 1rem;
    color: var(--clay-text-secondary);
    line-height: 1.6;
}

/* ===================================
   CRAFTING RESULT MODAL - IMPROVED
   =================================== */

#crafting-result-overlay {
    z-index: 2000; /* Keep z-index */
}

#crafting-result-modal {
    background: var(--gradient-dark); /* Use dark gradient */
    color: var(--clay-text-primary);
    padding: 1.5rem; /* Reduced padding */
    border-radius: 0.75rem; /* Slightly smaller radius */
    box-shadow: 0 10px 30px var(--clay-shadow-heavy), 0 0 0 1px var(--clay-border-light);
    max-width: 400px;
    width: 90%;
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center; /* Center align content */
}

#crafting-result-modal h2 {
    font-size: 1.375rem; /* Adjusted size */
    font-weight: 600; /* Adjusted weight */
    color: var(--clay-secondary); /* Use accent color */
    margin: 0 0 1rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#crafted-item-details {
    margin-bottom: 1.5rem;
}

#crafted-item-details img {
    width: 80px; /* Reduced size */
    height: 80px; /* Reduced size */
    margin: 0 auto 1rem;
    background-color: var(--clay-dark);
    border-radius: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--clay-border);
    box-shadow: 0 4px 10px var(--clay-shadow);
}

#crafted-item-details .item-name {
    font-size: 1.1rem; /* Adjusted size */
    font-weight: 600;
    margin-bottom: 0.25rem; /* Reduced margin */
    color: var(--clay-text-primary);
}

#crafted-item-details .item-type {
    display: none; /* Hide redundant type */
}

.item-main-stat {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--clay-highlight); /* Use highlight color for main stat */
    padding: 0.4rem 0.8rem;
    background: var(--clay-dark);
    border-radius: 0.375rem;
    border: 1px solid var(--clay-border);
    display: inline-block; /* Make it inline block */
}

.item-attributes-grid {
    display: flex; /* Use flex for centering */
    flex-direction: column; /* Stack vertically */
    gap: 0.5rem;
    text-align: left; /* Keep text aligned left within blocks */
    max-width: 250px; /* Constrain width */
    margin: 0 auto; /* Center the grid */
}

.item-attribute {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background-color: var(--clay-dark);
    border-radius: 0.375rem;
    border: 1px solid var(--clay-border);
    font-size: 0.875rem;
}

.item-attribute .label {
    text-transform: capitalize;
    color: var(--clay-text-secondary);
}

.item-attribute .value {
    font-weight: 600;
    color: var(--clay-text-primary);
    font-family: monospace;
}

#crafting-result-modal .modal-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    gap: 0.75rem; /* Reduced gap */
}

#crafting-result-modal .modal-buttons button {
    flex: 1; /* Buttons share space */
    padding: 0.6rem 1rem; /* Adjusted padding */
    font-size: 0.875rem; /* Adjusted size */
    /* Use clay-theme styles */
}
/* Apply specific styles if needed */
#crafting-modal-ok-btn { /* Neutral */
    background: var(--clay-dark);
    border-color: var(--clay-border);
    color: var(--clay-text-secondary);
}
#crafting-modal-equip-btn { /* Success/Accent */
    background: var(--gradient-accent);
    border-color: var(--clay-primary);
    color: var(--clay-text-primary);
}
#crafting-modal-discard-btn { /* Danger */
    background: var(--gradient-surface);
    border-color: var(--clay-error);
    color: var(--clay-error);
}


/* ===================================
   UTILITY CLASSES
   =================================== */

.hidden {
    display: none !important;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 768px) {
    main#content-wrapper {
        margin-left: 60px; /* Adjust for potentially smaller menu */
    }

    #main-view-column {
        padding: 1rem; /* Reduce padding on smaller screens */
    }

    #notification-container {
        top: 0.5rem;
        right: 0.5rem;
    }

    .notification-popup {
        width: 280px; /* Slightly smaller notifications */
    }

    .modal {
        padding: 1.5rem;
        margin: 1rem; /* Add margin around modal */
    }

    .modal-buttons {
        flex-direction: column; /* Stack buttons vertically */
    }

    .modal-buttons button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    /* On very small screens, consider making the menu horizontal at the bottom */
    /* Or keep it vertical but ensure content doesn't overlap */
    main#content-wrapper {
        margin-left: 0; /* Remove margin if menu is at bottom */
        padding-bottom: 60px; /* Add padding if menu is at bottom */
    }

    /* Example: Bottom Menu Styles (Uncomment and adjust if needed) */
    /*
    #side-menu {
        bottom: 0;
        top: auto;
        width: 100%;
        height: 60px;
        flex-direction: row;
        justify-content: space-around;
        padding: 0.5rem;
        border-top: 1px solid var(--clay-border);
        border-right: none;
    }
    .main-menu {
        flex-direction: row !important;
        width: 100%;
        justify-content: space-around;
        gap: 0.5rem;
    }
    .menu-item img {
        width: 40px;
        height: 40px;
    }
    .submenu {
        bottom: 70px;
        left: 50%;
        transform: translateX(-50%);
        width: auto;
    }
    */

    #notification-container {
        left: 0.5rem;
        right: 0.5rem;
        width: calc(100% - 1rem); /* Full width notifications */
    }

    .notification-popup {
        width: 100%;
    }
}

/* ===================================
   SMOOTH SCROLLING (For specific containers)
   =================================== */

/* Apply to elements that might scroll, like modals or columns */
.modal, #main-view-column, #combat-battlelog /* Add other scrollable elements */ {
    scroll-behavior: smooth;
}

/* ===================================
   ACCESSIBILITY
   =================================== */

/* Focus styles are handled in clay-theme.css */

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important; /* Disable smooth scroll */
    }
}

/* High contrast preference */
@media (prefers-contrast: high) {
    body {
        background-color: #000000;
        color: #ffffff;
    }

    .modal,
    .notification-popup,
    #loading-screen,
    #side-menu,
    button,
    input,
    select {
        background-color: #000000 !important; /* Force black background */
        border: 2px solid #ffffff !important; /* Force white border */
        color: #ffffff !important; /* Force white text */
    }
    /* Add more specific high-contrast overrides as needed */
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    #side-menu,
    #notification-container,
    .modal-overlay,
    #loading-screen {
        display: none !important;
    }

    main#content-wrapper {
        margin-left: 0;
    }

    body {
        background: white;
        color: black;
    }
    /* Add specific print styles to hide unnecessary UI elements */
    button, input, select {
        display: none;
    }
}

/* ===================================
   END OF MAIN STYLES
   =================================== */
