/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #fafafa;
    color: #2c3e50;
}

/* App layout */
#app {
    height: 100%;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.toolbar {
    background-color: #000;
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toolbar h1 {
    font-size: 20px;
    font-weight: 400;
    margin: 0;
}

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#nav {
    width: 250px;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    background-color: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
}

.app-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

/* Cards */
.card {
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.2), 0 2px 2px rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12);
    overflow: hidden;
    transition: box-shadow 0.3s;
}

/* Only elevate interactive cards on hover */
.card.room:hover,
#room-list .card:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.25), 0 3px 4px rgba(0,0,0,0.18);
}

.card-header {
    padding: 16px;
}

.card-title {
    font-size: 18px;
    font-weight: 500;
}

.card-content {
    padding: 16px;
}

.card-media {
    position: relative;
    overflow: hidden;
    perspective: 1000px;
}

.card-media img {
    width: 100%;
    display: block;
}

.card-actions {
    padding: 8px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-family: Roboto, sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    background: transparent;
    color: #000;
    min-width: 64px;
}

.btn:hover {
    background-color: rgba(0,0,0,0.08);
}

.btn-primary {
    color: #000;
    background-color: #e0e0e0;
}

.btn-primary:hover {
    background-color: #d0d0d0;
}

.btn-accent {
    color: #fff;
    background-color: #4caf50;
}

.btn-accent:hover {
    background-color: #43a047;
}

.btn-raised {
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-raised:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.25);
}

.btn-icon {
    min-width: auto;
    padding: 8px;
    border-radius: 50%;
}

.btn-icon .material-icons {
    font-size: 24px;
}

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4caf50;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* User tag in menu */
#user-tag {
    display: flex;
    align-items: center;
}

#user-avatar {
    flex: 0 0 auto;
    margin-right: 8px;
}

#user-name {
    flex: 1 0 auto;
    margin-left: 8px;
    cursor: pointer;
    font-weight: 500;
}

/* Menu rooms */
#menu-rooms {
    margin-top: 24px;
}

#menu-rooms header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 500;
}

#room-list .card + .card {
    margin-top: 16px;
}

/* Room component */
.room + .room {
    margin-top: 16px;
}

.room .header {
    color: #fff;
    background-color: #000;
}

.room .header .card-title {
    font-size: 14px;
    word-break: break-all;
}

.room .user-space {
    display: flex;
    flex-wrap: wrap;
    padding: 16px 8px 0;
    justify-content: center;
    gap: 16px;
}

.room .vote-button {
    height: 60px;
    width: 60px;
    font-size: 22px;
    border-radius: 50%;
}

/* User card */
.user-card {
    width: 150px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.user-card .card-header {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.user-card .name {
    font-size: 14px;
}

.user-card .user-pic {
    backface-visibility: hidden;
    transition: 1s ease-in-out;
}

.user-card .user-size {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 64px;
    transition: 1s ease-in-out;
    background: #fff;
}

/* Vote badges */
.vote-badge .material-icons {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    font-size: 20px;
}

.vote-badge .voted {
    color: green;
}

.vote-badge .not-voted {
    color: red;
}

.user-card.has-voted .vote-badge .voted {
    display: block;
}

.user-card:not(.has-voted) .vote-badge .not-voted {
    display: block;
}

/* show-vote class is on the .user wrapper div */
.user.show-vote .user-card.has-voted .user-pic {
    transform: rotateY(900deg);
}

.user.show-vote .user-card.has-voted .user-size {
    transform: rotateY(1080deg);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .user-card .user-pic,
    .user-card .user-size {
        transition: none;
    }
    .user.show-vote .user-card.has-voted .user-pic {
        transform: rotateY(180deg);
    }
    .user.show-vote .user-card.has-voted .user-size {
        transform: rotateY(360deg);
    }
}

/* Selected user highlight (randomize) */
.user.user-selected .user-card {
    box-shadow: 0 0 0 3px #4caf50, 0 3px 8px rgba(76, 175, 80, 0.4);
}

/* Home page */
.home {
    text-align: left;
}

/* Main page */
.main {
    position: relative;
}

#change-name-alert {
    position: absolute;
    left: 0;
    top: 0;
    margin: 0;
    z-index: 10;
}

#change-name-alert .card-content {
    display: flex;
    text-align: left;
}

#change-name-alert .material-icons {
    flex-grow: 0;
    margin-left: -8px;
    margin-right: 8px;
}

/* Error toast */
#error-toast {
    position: absolute;
    right: 0;
    top: 0;
    margin: 0;
    z-index: 10;
}

.error-toast {
    background-color: #ffebee;
    border-left: 4px solid #f44336;
}

.error-toast .card-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-toast .material-icons:first-child {
    color: #f44336;
}

/* Error page */
.error {
    text-align: left;
}

/* Empty state */
.empty-state {
    padding: 48px 16px;
    text-align: center;
    color: #999;
}

.empty-state .empty-icon {
    font-size: 80px;
    color: #ccc;
    margin-bottom: 16px;
}

.empty-state h2 {
    margin-bottom: 8px;
    font-weight: 500;
    color: #666;
}

.empty-state p {
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.5;
}

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

.dialog {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 11px 15px rgba(0,0,0,0.2);
    min-width: 280px;
    max-width: 480px;
    width: 100%;
    margin: 16px;
}

.dialog-title {
    padding: 24px 24px 0;
    font-size: 20px;
    font-weight: 500;
}

.dialog-content {
    padding: 16px 24px;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.dialog-content p + p {
    margin-top: 8px;
}

.dialog-body {
    padding: 0 24px 16px;
}

.dialog-input {
    width: 100%;
    padding: 8px 0;
    border: none;
    border-bottom: 2px solid #e0e0e0;
    font-family: Roboto, sans-serif;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.dialog-input:focus {
    border-bottom-color: #4caf50;
}

.dialog-actions {
    padding: 8px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

/* Responsive: small screens */
@media (max-width: 768px) {
    .app-body {
        flex-direction: column;
    }

    #nav {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 12px;
    }

    #menu-rooms {
        margin-top: 12px;
    }

    .room .vote-button {
        height: 48px;
        width: 48px;
        font-size: 18px;
    }

    .user-card {
        width: 120px;
    }

    .user-card .user-size {
        font-size: 48px;
    }
}

@media (max-width: 480px) {
    .user-card {
        width: 100px;
    }

    .user-card .user-size {
        font-size: 36px;
    }

    .room .vote-button {
        height: 40px;
        width: 40px;
        font-size: 16px;
    }
}
