.projects {
    padding: 2rem 0;
    width: 100%;
    direction: rtl;
    min-height: calc(410px * 2); /* Base height multiplier */
}

.projects .container {
    padding: 0;
    max-width: 1500px; /* Increased from default to accommodate 4 cards */
    margin: 0 auto;
    width: 100%;
}

.section-title {
    color: #ffffff;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    font-family: 'Tajawal', sans-serif;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(4, 350px); /* Force 4 columns of 350px each */
    gap: 16px;
    margin-top: 50px;
    width: 100%;
    justify-content: center;
}

.project-card {
    width: 350px;
    height: 350px;
    min-height: unset;
    background-color: #202f61;
    padding: 16px;
    border-radius: 16px;
    transition: all 500ms ease;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.project-card:hover {
    background-color: transparent;
    border: 1px solid #1e88e5;
}

.project-image {
    position: relative;
    flex: 8; /* Increased from 7 to give more space to image */
    width: 100%;
    height: 100%;
    margin-bottom: 8px; /* defaultPadding * 0.5 */
    border-radius: 12px;
    overflow: hidden;
}

.project-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
    border-radius: 8px; /* defaultPadding * 0.5 */
}

.project-card:hover .project-image img {
    transform: scale(1.05);
}

.project-content {
    flex: 4; /* Reduced from 5 to balance with larger image */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%; /* Ensure full width */
    height: 100%; /* Ensure full height */
}

.project-text {
    flex: 3;
    color: #fff;
    width: 100%;
    margin-bottom: 8px; /* defaultPadding * 0.5 */
}

.project-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-right: 0.5rem;
    color: white;
    display: block;
    margin-bottom: 4px;
}

.project-date {
    color: #9ca3af;
    font-size: 0.9rem;
    display: block;
    margin-top: 4px;
}

.project-description {
    color: #9ca3af;
    margin-top: 4px;
    font-size: 0.9rem;
    display: block;
    direction: ltr; /* Add LTR direction */
    text-align: left; /* Align text to the left */
}

.project-buttons {
    flex: 2;
    display: flex;
    justify-content: flex-start; /* Change from center to flex-start */
    gap: 1rem;
    direction: ltr; /* Force LTR for buttons */
    margin-top: auto; /* Push to bottom */
    padding: 8px 0; /* Add some padding */
    width: 100%; /* Use full width */
}

/* For small icons */
.project-buttons[data-small-icons="true"] {
    justify-content: flex-start; /* Change from space-evenly to flex-start */
}

.project-button {
    width: 40px;
    height: 40px;
    padding: 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.project-button:hover {
    background: rgba(255,255,255,0.2);
}

.project-button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.custom-button {
    height: 50px;
    width: 150px;
    background-color: black;
    border: none;
    border-radius: 8px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;  /* Add this line */
    gap: 16px; /* Add space between icon and text */
    direction: ltr; /* Ensure LTR inside button */
    white-space: nowrap; /* Add this to prevent text wrapping */
    max-width: 150px; /* Limit maximum width */
    width: 100%; /* Take available space */
}

.custom-button:hover {
    opacity: 0.9;
}

.button-icon {
    height: 25px;
    width: 25px;
    filter: brightness(0) invert(1);
    flex-shrink: 0; /* Prevent icon from shrinking */
}

.button-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    text-decoration: none;  /* Add this line */
}

.button-subtitle {
    color: #5B6152;
    font-size: 8px;
    font-weight: 700;
}

.button-title {
    color: white;
    font-size: 15px;
    font-weight: 700;
}

/* Store-specific button styles */
.custom-button[data-type="Google"] {
    background-color: #000000;
}

.custom-button[data-type="AppStore"] {
    background-color: #000000;
}

.custom-button[data-type="github"] {
    background-color: #000000;
}

.custom-button[data-type="Uptodown"] {
    background-color: #000000;
}

/* Add logo styles for buttons */
.button-icon[data-type="Google"] {
    content: url('../assets/svg/google-play.svg');
}

.button-icon[data-type="AppStore"] {
    content: url('../assets/svg/app-store.svg');
}

.button-icon[data-type="github"] {
    content: url('../assets/svg/github-svgrepo-com.svg');
}

.button-icon[data-type="Uptodown"] {
    content: url('../assets/svg/uptodown.svg');
}

@media (max-width: 1500px) {
    .projects-grid {
        grid-template-columns: repeat(3, 350px);
    }
}

@media (max-width: 1308px) {
    .projects {
        min-height: auto;
        padding-bottom: 2rem;
    }
}

@media (max-width: 1200px) {
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1120px) {
    .projects-grid {
        grid-template-columns: repeat(2, 350px);
    }
}

@media (max-width: 900px) {
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 797px) {
    .projects-grid {
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .projects-grid {
        grid-template-columns: 350px;
        justify-content: center; /* Center the grid */
    }

    .project-card {
        margin: 0 auto; /* Center individual cards */
        width: 100%; /* Take full width of grid cell */
        max-width: 350px; /* Maintain maximum width */
    }
}

@media (max-width: 600px) {
    .projects-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 430px) {
    .projects {
        padding: 2rem 0;
    }
}

/* Small screen button adjustments */
@media (max-width: 400px) {
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .project-card {
        width: 100%;
    }
}

@media (max-width: 311px) {
    .project-buttons {
        justify-content: flex-start; /* Keep consistent alignment */
    }
    
    .custom-button {
        width: auto;
        padding: 0 8px;
    }
}
