/*
 * Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
 * License granted by Canonical Limited
 *
 * This file is part of ubuntu-html5-ui-toolkit.
 *
 * This package is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or
 * (at your option) any later version.

 * This package is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this program. If not, see
 * <http://www.gnu.org/licenses/>
 */

/* ----------------------------------
 * Tabs
 * ---------------------------------- */

/* Workarround to load the Ubuntu Light font pad.lv/1186372 */
@font-face {
    font-family: 'Ubuntu';
    font-style: normal;
    font-weight: 300;
    src: local('Ubuntu Light'), local('Ubuntu-Light'), url(ubuntu-light.woff) format('woff');
}

@font-face {
    font-family: 'Ubuntu';
    font-style: normal;
    font-weight: 300;
    src: local('Ubuntu Light'), local('Ubuntu-Light'), url(ubuntu-light.woff) format('woff');
}

[data-role="header"] {
    background: #ededed;
    height: units_gu(7.5);
    width: 100%;
    position: fixed;
    z-index: 10;

    &:after {
        background: #c2c2c2;
        content: "";
        border-top: 1px solid #afafaf;
        height: 15px;
        width: 100%;
        display: block;
        position: absolute;
        top: 60px;
    }
}

[data-role="tabs"] {
    background: #ededed;
    -webkit-box-shadow: 0 0px 10px rgba(140, 140, 140, 0.3);
    box-shadow: 0 0px 10px rgba(140, 140, 140, 0.3);
    width: units_gu(20);
    max-height: 250px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    position: absolute;
    left: 0;
    top: 61px;
    z-index: 9;
    visibility: hidden;
    opacity: 0;
    transition: all 0.2s;

    &.opened {
        visibility: visible;
        opacity: 1;
    }
}

[data-role="tabitem"] {
    position: relative;
    padding: 16px units_gu(2);
    border-bottom: 1px solid #d9d9d9;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;

    &:only-child {
        border-bottom: 0;
    }

    &.active {
        display: none;
    }

    &.inactive {
        display: block;
    }

    &:active {
        background: rgba(0, 0, 0, 0.05);
    }
}

[data-role="back-btn"] {
    background: #ededed;
    width: units_gu(5);
    height: units_gu(7.5);
    line-height: units_gu(7.5);
    float: left;
    cursor: pointer;
    border: none;
    position: relative;

    &:after {
        content: "";
        display: block;
        width: units_gu(2.5);
        height: units_gu(2.5);
        background: transparent  url(icon(back)) no-repeat center center;
        background-size: 100%;
        margin: 0 auto;
    }

    &:disabled  {
        background: transparent;
        width: 0;
    }

    &:active {
        background: rgba(0, 0, 0, 0.05);
    }
}

[data-role="tabs-btn"] {
    background: #ededed;
    width: units_gu(5);
    height: units_gu(7.5);
    line-height: units_gu(7.5);
    float: left;
    cursor: pointer;
    border: none;

    position: relative;
    z-index: 10;

    &:after {
        content: "";
        display: block;
        width: units_gu(2.5);
        height: units_gu(2.5);
        background: transparent url(icon(navigation-menu)) no-repeat center center;
        background-size: 100%;
        margin: 0 auto;
    }

    &:active {
        background: rgba(0, 0, 0, 0.05);
    }
}

[data-role="back-btn"]:disabled+[data-role="tabtitle"],
[data-role="back-btn"]+[data-role="tabtitle"],
[data-role="tabs-btn"]+[data-role="tabtitle"],
[data-role="tabs"]+[data-role="tabtitle"] {
    width: calc(100% - 140px);
}

[data-role="tabtitle"] {
    font-family: $font_family;
    font-size: x-large;
    font-weight: 300;
    text-decoration: none;
    background: #ededed;
    color: $dark_grey;
    float: left;
    height: units_gu(7.5);
    line-height: units_gu(7.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    z-index: 10;
}

[data-role="tab"] {
    @include box_sizing (border-box);
    vertical-align: top;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: none;

    &:first-child {
        display: block;
    }
}

[data-role="actions"] {
    float: right;
    height: units_gu(7.5);
    display: inline-block;
    padding-right: units_gu(1);
    background: #ededed;
    position: relative;
    z-index: 10;

    button {
        border: 0;
        padding: 0;
        width: units_gu(5);
        height: units_gu(7.5);
        line-height: units_gu(7.5);
        cursor: pointer;
        float: left;
        background: transparent;

        img {
            position : relative;
            top: 5px;
        }

        &:disabled {
            opacity: 0.3;
        }

        &:after {
            content: "";
            display: block;
            width: units_gu(2.5);
            height: units_gu(2.5);
            background: transparent;
            background-size: 100%;
            margin: 0 auto;
        }

        &:active {
            background: rgba(0, 0, 0, 0.05);
        }
    }

    [data-role="actions-wrapper"] {
        display: none;

        &:first-child {
            display: block;
        }
    }
}

[data-role="actions-overflow-icon"] {
    background: transparent;

    &:after {
        content: "";
        display: block;
        width: units_gu(2.5);
        height: units_gu(2.5);
        background: transparent url(icon(contextual-menu)) no-repeat center center!important;
        background-size: 100%!important;
        margin: 0 auto;
    }

    &:active {
        background: rgba(0, 0, 0, 0.05);
    }
}

[data-role="actions-overflow-list"] {
    background: #ededed;
    -webkit-box-shadow: 0 0px 10px rgba(140, 140, 140, 0.3);
    box-shadow: 0 0px 10px rgba(140, 140, 140, 0.3);
    width: units_gu(20);
    max-height: 250px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    position: absolute;
    right: 0;
    top: 61px;
    z-index: 9;
    visibility: hidden;
    opacity: 0;
    transition: all 0.2s;

    &.opened {
        visibility: visible;
        opacity: 1;
    }

    li {
        position: relative;
        padding: 16px units_gu(2);
        border-bottom: 1px solid #d9d9d9;
        text-align: left;
        font-size: 0.8rem;
        cursor: pointer;
        text-align: left;
        padding-left: 45px;
        cursor: pointer;
        background: transparent no-repeat center left;
        background-size: 20px;
        background-position-x: 10px;

        &:only-child {
            border-bottom: 0;
        }

        &:active {
            background-color: rgba(0, 0, 0, 0.05);
        }
    }
}

[data-role="overlay"] {
    position: fixed;
    top: 75px;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9;
    background: transparent;
    display: none;

    &.active {
        display: block;
    }
}
